<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;"><div><br></div>  Yes, after the solve the x will contain correct values for ALL the locations including the (zeroed out rows). You use case is exactly what redistribute it for.<div><br></div><div>  Barry</div><div><br><div><br><blockquote type="cite"><div>On Jan 10, 2023, at 11:25 AM, Karthikeyan Chockalingam - STFC UKRI <karthikeyan.chockalingam@stfc.ac.uk> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; 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 style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Thank you Barry. This is great!<o:p></o:p></span></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">I plan to solve using ‘-</span><span style="font-size: 11pt;">pc_type redistribute’ after applying the Dirichlet bc using<o:p></o:p></span></div><div style="margin: 0cm; background-color: white; font-size: 9pt; font-family: Menlo;"><span class="s1" style="color: rgb(108, 54, 169);">MatZeroRowsColumnsIS</span>(<span class="s2" style="color: rgb(50, 109, 116);">A</span>,<span class="Apple-converted-space"> </span><span class="s2" style="color: rgb(50, 109, 116);">isout</span>,<span class="Apple-converted-space"> </span><span class="s3" style="color: rgb(28, 0, 207);">1</span>,<span class="Apple-converted-space"> </span><span class="s2" style="color: rgb(50, 109, 116);">x</span>,<span class="Apple-converted-space"> </span><span class="s2" style="color: rgb(50, 109, 116);">b)</span>;<span class="Apple-converted-space"> </span><o:p></o:p></div><div style="margin: 0cm; background-color: white; font-size: 9pt; font-family: Menlo;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">While I retrieve the solution data from x (after the solve) – can I index them using the original ordering (if I may say that)?<o:p></o:p></span></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Kind regards,<o:p></o:p></span></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Karthik.</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0cm 0cm;"><p class="MsoNormal" style="margin: 0cm 0cm 12pt; font-size: 10pt; font-family: Calibri, sans-serif;"><b><span style="font-size: 12pt;">From:<span class="Apple-converted-space"> </span></span></b><span style="font-size: 12pt;">Barry Smith <<a href="mailto:bsmith@petsc.dev" style="color: blue; text-decoration: underline;">bsmith@petsc.dev</a>><br><b>Date:<span class="Apple-converted-space"> </span></b>Tuesday, 10 January 2023 at 16:04<br><b>To:<span class="Apple-converted-space"> </span></b>Chockalingam, Karthikeyan (STFC,DL,HC) <<a href="mailto:karthikeyan.chockalingam@stfc.ac.uk" style="color: blue; text-decoration: underline;">karthikeyan.chockalingam@stfc.ac.uk</a>><br><b>Cc:<span class="Apple-converted-space"> </span></b><a href="mailto:petsc-users@mcs.anl.gov" style="color: blue; text-decoration: underline;">petsc-users@mcs.anl.gov</a><span class="Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" style="color: blue; text-decoration: underline;">petsc-users@mcs.anl.gov</a>><br><b>Subject:<span class="Apple-converted-space"> </span></b>Re: [petsc-users] Eliminating rows and columns which are zeros<o:p></o:p></span></p></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><a href="https://petsc.org/release/docs/manualpages/PC/PCREDISTRIBUTE/#pcredistribute" style="color: blue; text-decoration: underline;">https://petsc.org/release/docs/manualpages/PC/PCREDISTRIBUTE/#pcredistribute</a>   -pc_type redistribute<o:p></o:p></span></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">It does everything for you. Note that if the right hand side for any of the "zero" rows is nonzero then the system is inconsistent and the system does not have a solution.<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Barry<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><br><br><o:p></o:p></span></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt;"><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">On Jan 10, 2023, at 10:30 AM, Karthikeyan Chockalingam - STFC UKRI via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" style="color: blue; text-decoration: underline;">petsc-users@mcs.anl.gov</a>> wrote:<o:p></o:p></span></div></div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Hello,<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">I am assembling a MATIJ of size N, where a very large number of rows (and corresponding columns), are zeros. I would like to potentially eliminate them before the solve.<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">For instance say N=7<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif; background-color: white;"><span style="font-size: 9pt; font-family: Menlo; color: rgb(93, 108, 121);">0 0<span class="apple-converted-space">  </span>0<span class="apple-converted-space">  </span>0 0 0 0<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif; background-color: white;"><span style="font-size: 9pt; font-family: Menlo; color: rgb(93, 108, 121);">0 1 -1<span class="apple-converted-space">  </span>0 0 0 0<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif; background-color: white;"><span style="font-size: 9pt; font-family: Menlo; color: rgb(93, 108, 121);">0 -1 2<span class="apple-converted-space">  </span>0 0 0 -1<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif; background-color: white;"><span style="font-size: 9pt; font-family: Menlo; color: rgb(93, 108, 121);">0 0<span class="apple-converted-space">  </span>0<span class="apple-converted-space">  </span>0 0 0 0<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif; background-color: white;"><span style="font-size: 9pt; font-family: Menlo; color: rgb(93, 108, 121);">0 0<span class="apple-converted-space">  </span>0<span class="apple-converted-space">  </span>0 0 0 0<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif; background-color: white;"><span style="font-size: 9pt; font-family: Menlo; color: rgb(93, 108, 121);">0 0<span class="apple-converted-space">  </span>0<span class="apple-converted-space">  </span>0 0 0 0<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif; background-color: white;"><span style="font-size: 9pt; font-family: Menlo; color: rgb(93, 108, 121);">0 0<span class="apple-converted-space">  </span>-1 0 0 0 1<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">I would like to reduce it to a 3x3<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">1 -1 0<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">-1 2 -1<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">0 -1 1<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">I do know the size N.<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Q1) How do I do it?<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Q2) Is it better to eliminate them as it would save a lot of memory?<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Q3) At the moment, I don’t know which rows (and columns) have the zero entries but with some effort I probably can find them. Should I know which rows (and columns) I am eliminating?<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Thank you.<o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Karthik.<o:p></o:p></span></div></div><p style="caret-color: rgb(0, 0, 0); font-variant-caps: normal; text-align: start; -webkit-text-stroke-width: 0px; word-spacing: 0px;"><span style="font-size: 6pt; font-family: Helvetica;">This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses. </span></p></div></blockquote></div></div></div></div></blockquote></div><br></div></body></html>