<div dir="ltr">Dear PETSc developers            <div>Hi, </div><div><br></div><div><p style="margin:0px;white-space:pre-wrap"> I have been using SNES to solve a nonlinear problem recently, but this nonlinear problem is different from the ordinary problem, in which its residual function is a piecewise function.  I have the following questions during calculation:</p><p style="margin:0px"></p><ol style="white-space:pre-wrap"><li>As I am not very familiar with the jacobian matrix construction of this piecewise function, I used the - snes_fd.  However, the result is not converged in process of calculation. I don't know if it's the piecewise function problem or other errors.</li><li> For this piecewise function problem, it is actually determination of the residual function according to the current solution vector. Should I determine the piecewise function before each Newton step begins, or add judgment directly to the evaluation function to form the piecewise function? Now I'm adding judgment directly to the evaluation function to form a piecewise function.</li><li>Are there some special treatment for piecewise residual functions in the SNES?<br></li></ol><p></p><p style="margin:0px;white-space:pre-wrap">I'm dealing with a water two-phase flow problem, which is difficult to describe in detail because the model is relatively complex.  For the first time I have encountered this problem and hope to get some advice or information.</p><p style="margin:0px;white-space:pre-wrap"><br></p><p style="margin:0px;white-space:pre-wrap">Thanks,</p><p style="margin:0px;white-space:pre-wrap">Yingjie</p></div></div>