<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> This depends to some degree on how you are accessing applying the Jacobian construction process. <div class=""><br class=""></div><div class=""> If you are using SNES or TS then the SNES object handles most of the work of organizing the PETSc objects needed to compute the Jacobian and you can control the choices via the options database. </div><div class=""><br class=""></div><div class=""> With SNES/TS using a DM you can skip calling SNESSetJacobian() and simply use the option -snes_fd_color to have SNES compute the Jacobian for you. By default, the coloring is obtained from the DM (which is generally the best available coloring), you can have it use a coloring computed directly from the matrix structure with the options -snes_fd_color_use_mat -mat_coloring_type jp power sl lf ld or greedy (see MatColoringType, MatColoringSetFromOptions) Use -mat_fd_coloring_view to get information on the computation of the Jacobian from the coloring. Use -mat_coloring_view to get information on the coloring used. (see MatFDColoringSetFromOptions)</div><div class=""><br class=""></div><div class=""> If you are using SNES/TS but not using a DM you need to compute the nonzero structure of the matrix yourself into J and call SNESSetJacobian(snes,J,J,SNESComputeJacobianDefaultColor,matfdcoloring); you need to create the matfdcoloring object with MatFDColoringCreate() using an iscoloring you obtained with MatColoringCreate() etc. The same command line arguments as above allow you to control the coloring algorithm used and to view them etc.</div><div class=""><br class=""></div><div class=""> Barry</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On May 10, 2022, at 11:40 AM, Jorti, Zakariae via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class="">Hi,<span class="Apple-converted-space"> </span><br class=""><br class="">I am solving a non-linear problem and using a finite difference approximation with coloring to compute the Jacobian matrix.<br class=""><br class=""></div><div class="">There are several coloring algorithms available in PETSc as indicated here:<br class=""><a href="https://petsc.org/release/docs/manualpages/Mat/MatColoring.html" class="">https://petsc.org/release/docs/manualpages/Mat/MatColoring.html</a><br class=""><br class="">And I was wondering how to switch from one to another in the Jacobian setup routine and also how to check which coloring algorithm I am currently using.<br class=""></div><br class=""><div style="margin-top: 0px; margin-bottom: 0px;" class="">Thank you.</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Zakariae Jorti</div></div></div></blockquote></div><br class=""></div></body></html>