<div dir="ltr"><div dir="ltr">On Wed, Nov 16, 2022 at 9:07 PM Zhang, Hong 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="msg7487228530054485512">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-family:Menlo;font-size:12px;background-color:rgb(255,255,255);display:inline">Karhik,</span><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-family:Menlo;font-size:12px;background-color:rgb(255,255,255);display:inline">Can you find out the condition number of your matrix?</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-family:Menlo;font-size:12px;background-color:rgb(255,255,255);display:inline"></span></div></div></div></blockquote><div><br></div><div>Also, run using</div><div><br></div><div>  -ksp_view -ksp_monitor_true_residual -ksp_converged_reason</div><div><br></div><div>and send the two outputs.</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="msg7487228530054485512"><div dir="ltr"><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-family:Menlo;font-size:12px;background-color:rgb(255,255,255);display:inline">Hong</span></div>
<div id="m_-7607706715142363214signature_bookmark"></div>
<div id="m_-7607706715142363214appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<hr style="display:inline-block;width:98%">
<div id="m_-7607706715142363214divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> petsc-users <<a href="mailto:petsc-users-bounces@mcs.anl.gov" target="_blank">petsc-users-bounces@mcs.anl.gov</a>> on behalf of Karthikeyan Chockalingam - STFC UKRI via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Sent:</b> Wednesday, November 16, 2022 6:04 PM<br>
<b>To:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a> <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> [petsc-users] Different solution while running in parallel</font>
<div> </div>
</div>
<div lang="EN-GB" style="overflow-wrap: break-word;">
<div>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>  Hello,</span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span> </span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>   I tried to solve a (FE discretized) Poisson equation using PCLU. For some reason I am getting different solutions while running the problem on one and two cores. I have attached the output file (out.txt) from both the
 runs. I am printing A, b and x from both the runs – while A and b are the same but the solution seems is different.</span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span> </span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>I am not sure what I doing wrong.</span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span> </span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>Below is my matrix, vector, and solve setup.
</span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span> </span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span> </span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>   </span> <span style="color:rgb(57,0,160)">Mat</span> A;<span style="color:rgb(57,0,160)"></span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">    </span><span style="font-size:9pt;font-family:Menlo;color:rgb(57,0,160)">Vec</span><span style="font-size:9pt;font-family:Menlo;color:black"> b, x;</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">    </span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">    ierr = </span><span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">MatCreate</span><span style="font-size:9pt;font-family:Menlo;color:black">(</span><span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">PETSC_COMM_WORLD</span><span style="font-size:9pt;font-family:Menlo;color:black">,
 &A); </span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">CHKERRQ</span><span style="font-size:9pt;font-family:Menlo;color:black">(ierr);</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">    ierr = </span><span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">MatSetType</span><span style="font-size:9pt;font-family:Menlo;color:black">(A,
</span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">MATMPIAIJ</span><span style="font-size:9pt;font-family:Menlo;color:black">);
</span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">CHKERRQ</span><span style="font-size:9pt;font-family:Menlo;color:black">(ierr);</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">    ierr = </span><span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">MatSetSizes</span><span style="font-size:9pt;font-family:Menlo;color:black">(A,
</span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">PETSC_DECIDE</span><span style="font-size:9pt;font-family:Menlo;color:black">,
</span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">PETSC_DECIDE</span><span style="font-size:9pt;font-family:Menlo;color:black">, N, N);
</span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">CHKERRQ</span><span style="font-size:9pt;font-family:Menlo;color:black">(ierr);</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">    ierr = </span><span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">MatMPIAIJSetPreallocation</span><span style="font-size:9pt;font-family:Menlo;color:black">(A,d_nz,
</span><b><span style="font-size:9pt;font-family:Menlo;color:rgb(155,35,147)">NULL</span></b><span style="font-size:9pt;font-family:Menlo;color:black">, o_nz,
</span><b><span style="font-size:9pt;font-family:Menlo;color:rgb(155,35,147)">NULL</span></b><span style="font-size:9pt;font-family:Menlo;color:black">);
</span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">CHKERRQ</span><span style="font-size:9pt;font-family:Menlo;color:black">(ierr);</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">    ierr = MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);
</span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">CHKERRQ</span><span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">(ierr);</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">    ierr = </span><span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">MatCreateVecs</span><span style="font-size:9pt;font-family:Menlo;color:black">(A, &b, &x);
</span><span style="font-size:9pt;font-family:Menlo;color:rgb(100,56,32)">CHKERRQ</span><span style="font-size:9pt;font-family:Menlo;color:black">(ierr);</span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
 </p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>    </span><span style="color:rgb(57,0,160)">KSP</span>
<span>          </span>ksp;</p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>    </span><span style="color:rgb(57,0,160)">PC</span><span>           
</span>pc;</p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">
<span>    </span>KSPCreate<span>(</span>PETSC_COMM_WORLD<span>, &ksp);</span></p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>    </span><span style="color:rgb(108,54,169)">KSPSetOperators</span>(ksp, A, A);</p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>    </span>ierr = <span style="color:rgb(108,54,169)">
KSPSetType</span>(ksp,<span style="color:rgb(100,56,32)">KSPPREONLY</span>);<span style="color:rgb(100,56,32)">CHKERRQ</span>(ierr);</p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>    </span>ierr = <span style="color:rgb(108,54,169)">
KSPGetPC</span>(ksp,&pc);<span style="color:rgb(100,56,32)">CHKERRQ</span>(ierr);</p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:black">
<span>    </span>ierr = <span style="color:rgb(108,54,169)">
PCSetType</span>(pc,<span style="color:rgb(100,56,32)">PCLU</span>);<span style="color:rgb(100,56,32)">CHKERRQ</span>(ierr);</p>
<p style="margin:0cm;background:white;font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">
<span>    </span><span>ierr = </span>
PCFactorSetMatSolverType<span>(pc,</span><span style="color:rgb(100,56,32)">MATSOLVERMUMPS</span><span>);</span><span style="color:rgb(100,56,32)">CHKERRQ</span><span>(ierr);</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">    </span><span style="font-size:9pt;font-family:Menlo;color:rgb(108,54,169)">KSPSolve</span><span style="font-size:9pt;font-family:Menlo;color:black">(ksp, b, x);</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black"> </span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">Thank you for your help.</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black"> </span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;background:white">
<span style="font-size:9pt;font-family:Menlo;color:black">Karhik.</span></p>
<p style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
</div>
<p><span style="font-size:6pt">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>
</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="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>