<html xmlns:v="urn:schemas-microsoft-com:vml" 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)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@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:9.0pt;
font-family:Menlo;
color:#5D6C79;}
p.p2, li.p2, div.p2
{mso-style-name:p2;
margin:0cm;
background:white;
font-size:9.0pt;
font-family:Menlo;
color:black;}
p.p3, li.p3, div.p3
{mso-style-name:p3;
margin:0cm;
background:white;
font-size:9.0pt;
font-family:Menlo;
color:#3900A0;}
p.p4, li.p4, div.p4
{mso-style-name:p4;
margin:0cm;
background:white;
font-size:9.0pt;
font-family:Menlo;
color:#6C36A9;}
span.s2
{mso-style-name:s2;
color:#3900A0;}
span.s3
{mso-style-name:s3;
color:#643820;}
span.s1
{mso-style-name:s1;}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
span.EmailStyle28
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.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><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:black;mso-fareast-language:EN-US">I also get the following bit get the converged reason.</span><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0"> KSPConvergedReason reason;<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" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9"> KSPGetConvergedReason(ksp, &reason);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">
</span><b><span style="font-size:9.0pt;font-family:Menlo;color:#9B2393">if</span></b><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9"> (reason == KSP_DIVERGED_INDEFINITE_PC) {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PetscPrintf</span><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">(</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PETSC_COMM_WORLD</span><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">,
"\nDivergence because of indefinite preconditioner;\n");<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PetscPrintf</span><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">(</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PETSC_COMM_WORLD</span><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">,
"Run the executable again but with '-pc_factor_shift_type POSITIVE_DEFINITE' option.\n");<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> }
</span><b><span style="font-size:9.0pt;font-family:Menlo;color:#9B2393">else</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">
</span><b><span style="font-size:9.0pt;font-family:Menlo;color:#9B2393">if</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black"> (reason <
</span><span style="font-size:9.0pt;font-family:Menlo;color:#1C00CF">0</span><span style="font-size:9.0pt;font-family:Menlo;color:black">) {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PetscPrintf</span><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">(</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PETSC_COMM_WORLD</span><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">,
"\nOther kind of divergence: this should not happen.\n");<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> }
</span><b><span style="font-size:9.0pt;font-family:Menlo;color:#9B2393">else</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black"> {<o:p></o:p></span></p>
<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;color:#6C36A9">KSPGetIterationNumber</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp, &its);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PetscPrintf</span><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">(</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PETSC_COMM_WORLD</span><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">,"\nConvergence
in %d iterations.\n",(</span><b><span style="font-size:9.0pt;font-family:Menlo;color:#9B2393">int</span></b><span style="font-size:9.0pt;font-family:Menlo;color:#C41A16">)its);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> }<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">Best,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Karthik.<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">Chockalingam, Karthikeyan (STFC,DL,HC) <karthikeyan.chockalingam@stfc.ac.uk><br>
<b>Date: </b>Thursday, 17 November 2022 at 14:37<br>
<b>To: </b>Matthew Knepley <knepley@gmail.com>, Zhang, Hong <hzhang@mcs.anl.gov><br>
<b>Cc: </b>petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject: </b>Re: [petsc-users] Different solution while running in parallel<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Hi Matt and Hong,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Thank you for your response.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">I made the following changes, to get the desired output
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s2">PetscReal</span><span class="s1"> norm;
</span>/* norm of solution error */<o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s2">PetscInt</span><span class="apple-converted-space">
</span>its;<o:p></o:p></p>
<p class="p3"><span class="apple-converted-space"> </span>KSPConvergedReason<span class="s1"> reason;</span><o:p></o:p></p>
<p class="p3"><span class="apple-converted-space"> </span>PetscViewerAndFormat<span class="s1"> *vf;</span><o:p></o:p></p>
<p class="p4"><span class="apple-converted-space"> </span>PetscViewerAndFormatCreate<span class="s1">(</span><span class="s3">PETSC_VIEWER_STDOUT_WORLD</span><span class="s1">,
</span>PETSC_VIEWER_DEFAULT<span class="s1">, &vf);</span><o:p></o:p></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#643820"> </span><o:p></o:p></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#643820"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPView</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">(ksp, PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);</span><o:p></o:p></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<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;color:#6C36A9">KSPSolve</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp, b, x);</span><o:p></o:p></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPMonitorTrueResidual</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp,its,norm,vf);</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPMonitorSingularValue</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp, its, norm, vf);</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">I have attached the outputs from both the runs. As before, I am also printing A, b, and x.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">I wonder if it is a memory issue related to mpi library employed. I am currently using openmpi – should I instead use mpich?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Kind regards,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Karthik.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"> </span><o:p></o:p></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">Matthew Knepley <knepley@gmail.com><br>
<b>Date: </b>Thursday, 17 November 2022 at 12:19<br>
<b>To: </b>Zhang, Hong <hzhang@mcs.anl.gov><br>
<b>Cc: </b>petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov>, Chockalingam, Karthikeyan (STFC,DL,HC) <karthikeyan.chockalingam@stfc.ac.uk><br>
<b>Subject: </b>Re: [petsc-users] Different solution while running in parallel</span><o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">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:</span><o:p></o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black;background:white">Karhik,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black;background:white">Can you find out the condition number of your matrix?</span><o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Also, run using</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> -ksp_view -ksp_monitor_true_residual -ksp_converged_reason</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">and send the two outputs.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> Thanks,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> Matt</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black;background:white">Hong</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"> </span><o:p></o:p></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center"><span style="font-size:11.0pt">
<hr size="0" width="100%" align="center">
</span></div>
<div id="m_-7607706715142363214divRplyFwdMsg">
<p class="MsoNormal"><b><span style="font-size:11.0pt;color:black">From:</span></b><span style="font-size:11.0pt;color:black"> 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</span><span style="font-size:11.0pt">
</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
</div>
<div>
<div>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> Hello,</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> 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><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">I am not sure what I doing wrong.</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">Below is my matrix, vector, and solve setup.
</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0">Mat</span><span style="font-size:9.0pt;font-family:Menlo;color:black"> A;</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0">Vec</span><span style="font-size:9.0pt;font-family:Menlo;color:black"> b, x;</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">MatCreate</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PETSC_COMM_WORLD</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,
&A); </span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">MatSetType</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(A,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">MATMPIAIJ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">);
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">MatSetSizes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(A,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">PETSC_DECIDE</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">PETSC_DECIDE</span><span style="font-size:9.0pt;font-family:Menlo;color:black">, N, N);
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">MatMPIAIJSetPreallocation</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(A,d_nz,
</span><b><span style="font-size:9.0pt;font-family:Menlo;color:#9B2393">NULL</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">, o_nz,
</span><b><span style="font-size:9.0pt;font-family:Menlo;color:#9B2393">NULL</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">);
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9"> ierr = MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">MatCreateVecs</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(A, &b, &x);
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0">KSP</span><span style="font-size:9.0pt;font-family:Menlo;color:black"> ksp;</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0">PC</span><span style="font-size:9.0pt;font-family:Menlo;color:black"> pc;</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9"> KSPCreate(PETSC_COMM_WORLD, &ksp);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPSetOperators</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp, A, A);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPSetType</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp,</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">KSPPREONLY</span><span style="font-size:9.0pt;font-family:Menlo;color:black">);</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPGetPC</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp,&pc);</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">PCSetType</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(pc,</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">PCLU</span><span style="font-size:9.0pt;font-family:Menlo;color:black">);</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9"> ierr = PCFactorSetMatSolverType(pc,</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">MATSOLVERMUMPS</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">);</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">(ierr);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPSolve</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp, b, x);</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">Thank you for your help.</span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><o:p></o:p></p>
<p style="margin:0cm;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">Karhik.</span><o:p></o:p></p>
<p style="margin:0cm"> <o:p></o:p></p>
</div>
<p><span style="font-size:6.0pt">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><o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><br clear="all">
</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt">-- </span><o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">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</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a></span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>