<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p>Hello,<br>
<br>
I have used the -mat_coloring_view and -mat_fd_coloring_view flags as you suggested and it turns out that the coloring used was
<span>MATCOLORINGSL. <br>
</span></p>
<p><span>I have also tried other methods and obtained the following numbers of function evaluations per Jacobian building:  
</span><br>
- MATCOLORINGJP : 593<br>
<span>- MATCOLORINGID : 327</span></p>
<p><span>- MATCOLORINGSL : 321</span></p>
<p><span>- MATCOLORINGGREEDY : 316</span></p>
<p><span>- MATCOLORINGLF : </span>230<br>
<br>
<span>Is there any parameter/trick we can try to further cut down the number of function evaluations? And also how could we use MATCOLORINGMIS as this latter does not appear in the MatColoringType options?<br>
Many thanks.</span><br>
<br>
Zakariae<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Tang, Qi <tangqi@msu.edu><br>
<b>Sent:</b> Tuesday, May 10, 2022 10:51:07 AM<br>
<b>To:</b> Barry Smith; petsc-users@mcs.anl.gov<br>
<b>Cc:</b> Jorti, Zakariae; Tang, Xianzhu<br>
<b>Subject:</b> [EXTERNAL] Re: [petsc-users] MatColoring</font>
<div> </div>
</div>
<div>We are using SNES + TS + dmstag. The current bottleneck is the number of residual evaluation (more than 300 per Jacobian building using the default coloring from dmstag). We talked to Patrick and we are not sure how to improve further.
<div class=""><br class="">
</div>
<div class="">So it looks like we should play with mat_coloring_type and see if others give us better performance.</div>
<div class=""><br class="">
</div>
<div class="">If there is anything else we can play with, please also let us know. We also lag Jacobian and only build once every three Newton iterations, which works well. Thanks,</div>
<div class=""><br class="">
</div>
<div class="">Qi<br class="">
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On May 10, 2022, at 10:35 AM, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="" style="word-wrap:break-word; line-break:after-white-space">
<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 class=""><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="">
<div id="divtagdefaultwrapper" dir="ltr" class="" style="font-style: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div class="" style="margin-top:0px; margin-bottom:0px">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://urldefense.com/v3/__https://petsc.org/release/docs/manualpages/Mat/MatColoring.html__;!!HXCxUKc!1czn7o25s7aYCp0mPqVxWzr-S-Fc0qBskSUMuqiRAf5CiUQoJAYOwuyAak2yJhKKkULePn_T7-fyd0U$" 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 class="" style="margin-top:0px; margin-bottom:0px">Thank you.</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px">Zakariae Jorti</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</div>
</body>
</html>