<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">I set up 2 KSPs through KSPSetComputeOperators, <span style="font-size: 10pt;">with separate compute matrix functions. </span>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    </p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    ierr = KSPSetComputeOperators(ksp1,ComputeMatrix1,<span style="color: #bb2ca2">NULL</span>);CHKERRQ(ierr);</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    ierr = KSPSetComputeOperators(ksp2,ComputeMatrix2,<span style="color: #bb2ca2">NULL</span>);CHKERRQ(ierr);</p>
<div><span style="font-size: 10pt;"><br>
</span></div>
<div>Within each computeMatrix function, I define the matrix, and I also print something to the screen. So</div>
<div><br>
</div>
<div>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
PetscErrorCode ComputeMatrix1(KSP ksp, Mat J,Mat jac, <span style="color: #bb2ca2">
void</span> *ctx)</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
{</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    ......</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    ierr    = PetscPrintf(PETSC_COMM_WORLD,<span style="color: rgb(209, 47, 27);">"1\n"</span>);CHKERRQ(ierr);</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    ......</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
}</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
PetscErrorCode ComputeMatrix2(KSP ksp, Mat J,Mat jac, <span style="color: rgb(187, 44, 162);">void</span> *ctx)</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
{</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    ......</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    ierr    = PetscPrintf(PETSC_COMM_WORLD,<span style="color: rgb(209, 47, 27);">"2\n"</span>);CHKERRQ(ierr);</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
    ......</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
}</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; font-family: Menlo;">
<br>
</p>
</div>
<div>Now if I compile and execute the code, it only print 2, completely ignoring 1, which is not expected, since I have setup ksp1 to use ComputeMatrix1. </div>
<div><br>
</div>
<div>Does anyone know what might be wrong? Thank you. I have attached the short code here in this email as well. </div>
<div><br>
</div>
<div>Hui</div>
</div>
</body>
</html>