<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Menlo;
        panose-1:2 11 6 9 3 8 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
p.p1, li.p1, div.p1
        {mso-style-name:p1;
        margin:0cm;
        background:white;
        font-size:8.5pt;
        font-family:Menlo;
        color:black;}
span.s1
        {mso-style-name:s1;}
span.s2
        {mso-style-name:s2;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.s3
        {mso-style-name:s3;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-GB" link="blue" vlink="purple" style="word-wrap:break-word;overflow-wrap: break-word;-webkit-nbsp-mode: space;line-break:after-white-space">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Hello Barry,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">I would like to better understand
</span><span style="font-size:11.0pt">pc_type redistribute usage. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I am plan to use pc_type <u>redistribute</u> in the context of adaptive mesh refinement on a structured grid in 2D. My base mesh (level 0) is indexed from 0 to N-1 elements and refined mesh (level 1) is indexed
 from 0 to 4(N-1) elements. When I construct system matrix A on (level 1); I probably only use 20% of 4(N-1)  elements, however the indexes are scattered in the range of 0 to 4(N-1). That leaves 80% of the rows and columns of the system matrix A on (level 1)
 to be zero. From your earlier response, I believe this would be a use case for petsc_type redistribute.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Question (1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">If N is really large, I would have to allocate memory of size 4(N-1) for the system matrix A on (level 1). How does pc_type redistribute<u>
</u>help? Because, I did end up allocating memory for a large system, where most of the rows and columns are zeros. Is most of the allotted memory not wasted?<u> Is this the correct usage?<o:p></o:p></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Question (2)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I tried using pc_type redistribute for a two level system.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I have <b><u>attached</u></b> the output only for  (level 1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The solution converges to right solution but still petsc outputs some error messages.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">[0]PETSC ERROR: WARNING! There are option(s) set that were not used! Could be the program crashed before they were used or a spelling mistake, etc!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">[0]PETSC ERROR: Option left: name:-options_left (no value)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">But the there were no unused options<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#PETSc Option Table entries:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-ksp_type preonly<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-options_left<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-pc_type redistribute<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-redistribute_ksp_converged_reason<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-redistribute_ksp_monitor_true_residual<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-redistribute_ksp_type cg<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-redistribute_ksp_view<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-redistribute_pc_type jacobi<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#End of PETSc Option Table entries<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt">There are no unused options.<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Program ended with exit code: 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
<br>
Question (2)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="p1"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">[0;39m[0;49m[0]PETSC ERROR: Object is in wrong state<o:p></o:p></span></p>
<p class="p1"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">[0]PETSC ERROR: Matrix is missing diagonal entry in row 0 (65792)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">What does this error message imply? Given I only use 20% of 4(N-1) indexes, I can imagine most of the diagonal entrees are zero.
<u>Is my understanding correct?</u><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Question (3)<br>
<br>
<o:p></o:p></span></p>
<p class="p1">[0]PETSC ERROR: #5 MatZeroRowsColumnsIS() at /Users/karthikeyan.chockalingam/AMReX/SRC_PKG/petsc/src/mat/interface/matrix.c:6124</p>
<p class="p1"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I am using MatZeroRowsColumnsIS to set the homogenous Dirichelet boundary. I don’t follow why I get this error message as the linear system converges to the right solution.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thank you for your help.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Kind regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Karthik.<o:p></o:p></span></p>
<p class="p1"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Barry Smith <bsmith@petsc.dev><br>
<b>Date: </b>Tuesday, 10 January 2023 at 18:50<br>
<b>To: </b>Chockalingam, Karthikeyan (STFC,DL,HC) <karthikeyan.chockalingam@stfc.ac.uk><br>
<b>Cc: </b>petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject: </b>Re: [petsc-users] Eliminating rows and columns which are zeros<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt">  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.<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">  Barry<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On Jan 10, 2023, at 11:25 AM, Karthikeyan Chockalingam - STFC UKRI <karthikeyan.chockalingam@stfc.ac.uk> wrote:<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Thank you Barry. This is great!</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">I plan to solve using ‘-pc_type redistribute’ after applying the Dirichlet bc using</span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="s1"><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">MatZeroRowsColumnsIS</span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span class="s2"><span style="font-size:9.0pt;font-family:Menlo;color:#326D74">A</span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span class="s2"><span style="font-size:9.0pt;font-family:Menlo;color:#326D74">isout</span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span class="s3"><span style="font-size:9.0pt;font-family:Menlo;color:#1C00CF">1</span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span class="s2"><span style="font-size:9.0pt;font-family:Menlo;color:#326D74">x</span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span class="s2"><span style="font-size:9.0pt;font-family:Menlo;color:#326D74">b)</span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">;<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:9.0pt;font-family:Menlo"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">While I retrieve the solution data from x (after the solve) – can I index them using the original ordering (if I may say that)?</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Kind regards,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Karthik.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt">From:<span class="apple-converted-space"> </span></span></b><span style="font-size:12.0pt">Barry Smith <</span><a href="mailto:bsmith@petsc.dev"><span style="font-size:12.0pt">bsmith@petsc.dev</span></a><span style="font-size:12.0pt">><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) <</span><a href="mailto:karthikeyan.chockalingam@stfc.ac.uk"><span style="font-size:12.0pt">karthikeyan.chockalingam@stfc.ac.uk</span></a><span style="font-size:12.0pt">><br>
<b>Cc:<span class="apple-converted-space"> </span></b></span><a href="mailto:petsc-users@mcs.anl.gov"><span style="font-size:12.0pt">petsc-users@mcs.anl.gov</span></a><span class="apple-converted-space"><span style="font-size:12.0pt"> </span></span><span style="font-size:12.0pt"><</span><a href="mailto:petsc-users@mcs.anl.gov"><span style="font-size:12.0pt">petsc-users@mcs.anl.gov</span></a><span style="font-size:12.0pt">><br>
<b>Subject:<span class="apple-converted-space"> </span></b>Re: [petsc-users] Eliminating rows and columns which are zeros</span><o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<p class="MsoNormal"><a href="https://petsc.org/release/docs/manualpages/PC/PCREDISTRIBUTE/#pcredistribute"><span style="font-size:11.0pt">https://petsc.org/release/docs/manualpages/PC/PCREDISTRIBUTE/#pcredistribute</span></a><span style="font-size:11.0pt"> 
  -pc_type redistribute</span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">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.</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Barry</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
<br>
<br>
</span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On Jan 10, 2023, at 10:30 AM, Karthikeyan Chockalingam - STFC UKRI via petsc-users <</span><a href="mailto:petsc-users@mcs.anl.gov"><span style="font-size:11.0pt">petsc-users@mcs.anl.gov</span></a><span style="font-size:11.0pt">>
 wrote:</span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Hello,</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">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.</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">For instance say N=7</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#5D6C79">0 0<span class="apple-converted-space">  </span>0<span class="apple-converted-space">  </span>0 0 0 0</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#5D6C79">0 1 -1<span class="apple-converted-space">  </span>0 0 0 0</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#5D6C79">0 -1 2<span class="apple-converted-space">  </span>0 0 0 -1</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#5D6C79">0 0<span class="apple-converted-space">  </span>0<span class="apple-converted-space">  </span>0 0 0 0</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#5D6C79">0 0<span class="apple-converted-space">  </span>0<span class="apple-converted-space">  </span>0 0 0 0</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#5D6C79">0 0<span class="apple-converted-space">  </span>0<span class="apple-converted-space">  </span>0 0 0 0</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#5D6C79">0 0<span class="apple-converted-space">  </span>-1 0 0 0 1</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">I would like to reduce it to a 3x3</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">1 -1 0</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">-1 2 -1</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">0 -1 1</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">I do know the size N.</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Q1) How do I do it?</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Q2) Is it better to eliminate them as it would save a lot of memory?</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">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?</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Thank you.</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Karthik.</span><o:p></o:p></p>
</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:6.0pt;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><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
</div>
</body>
</html>