Hello,

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 MATCOLORINGSL.

I have also tried other methods and obtained the following numbers of function 
evaluations per Jacobian building:
- MATCOLORINGJP : 593
- MATCOLORINGID : 327

- MATCOLORINGSL : 321

- MATCOLORINGGREEDY : 316

- MATCOLORINGLF : 230

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?
Many thanks.

Zakariae

________________________________
From: Tang, Qi <[email protected]>
Sent: Tuesday, May 10, 2022 10:51:07 AM
To: Barry Smith; [email protected]
Cc: Jorti, Zakariae; Tang, Xianzhu
Subject: [EXTERNAL] Re: [petsc-users] MatColoring

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.

So it looks like we should play with mat_coloring_type and see if others give 
us better performance.

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,

Qi


On May 10, 2022, at 10:35 AM, Barry Smith 
<[email protected]<mailto:[email protected]>> wrote:


  This depends to some degree on how you are accessing applying the Jacobian 
construction process.

   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.

   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)

  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.

  Barry








On May 10, 2022, at 11:40 AM, Jorti, Zakariae via petsc-users 
<[email protected]<mailto:[email protected]>> wrote:

Hi,

I am solving a non-linear problem and using a finite difference approximation 
with coloring to compute the Jacobian matrix.

There are several coloring algorithms available in PETSc as indicated here:
https://petsc.org/release/docs/manualpages/Mat/MatColoring.html<https://urldefense.com/v3/__https://petsc.org/release/docs/manualpages/Mat/MatColoring.html__;!!HXCxUKc!1czn7o25s7aYCp0mPqVxWzr-S-Fc0qBskSUMuqiRAf5CiUQoJAYOwuyAak2yJhKKkULePn_T7-fyd0U$>

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.

Thank you.

Zakariae Jorti


Reply via email to