<div dir="ltr">Do you mean a piecewise smooth function, with a discontinuous derivative, or a piecewise function which is itself discontinuous?<div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 5, 2020 at 11:05 PM Yingjie Wu <<a href="mailto:yjwu16@gmail.com">yjwu16@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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>
</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>