[petsc-users] Auto sparsity detection?

Matthew Knepley knepley at gmail.com
Thu Jan 16 21:01:26 CST 2025


On Thu, Jan 16, 2025 at 9:50 PM Zou, Ling via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hi all,
>
>
>
> Does PETSc has some automatic matrix sparsity detection algorithm
> available?
>
> Something like:
> https://urldefense.us/v3/__https://docs.sciml.ai/NonlinearSolve/stable/basics/sparsity_detection/__;!!G_uCfscf7eWS!dvR7knTNgJjVsN8MbdkzqHYGMeFeJA5KRmWbLart8sNlv5MD6vaocv12fo_IltMmctrA04DuDQsTXfRFd2UH$ 
> <https://urldefense.us/v3/__https://docs.sciml.ai/NonlinearSolve/stable/basics/sparsity_detection/__;!!G_uCfscf7eWS!ccEx6zmuNrVADqtN50hO2N0k4Qs-A70nztAjMLu-JElnjhK5w84BpYC8CAINd6KihSxaS2rx_LgpqUVM49U$>
>

Sparsity detection would rely on introspection of the user code for
ComputeFunction(), which is not
possible in C (unless you were to code up your evaluation in some symbolic
framework).


> The background is that I use finite differencing plus matrix coloring to
> (efficiently) get the Jacobian.
>
> For the matrix coloring part, I color the matrix based on mesh
> connectivity and variable dependencies, which is not bad, but just try to
> be lazy to even eliminating this part.
>

This is how the automatic frameworks also work. This is how we compute the
sparsity pattern for PetscFE and PetscFV.


> A related but different question, how much does PETSc support automatic
> differentiation?
>
> I see some old paper:
>
> https://ftp.mcs.anl.gov/pub/tech_reports/reports/P922.pdf
>
> and discussion in the roadmap:
>
> https://urldefense.us/v3/__https://petsc.org/release/community/roadmap/__;!!G_uCfscf7eWS!dvR7knTNgJjVsN8MbdkzqHYGMeFeJA5KRmWbLart8sNlv5MD6vaocv12fo_IltMmctrA04DuDQsTXRy5JWAw$ 
> <https://urldefense.us/v3/__https://petsc.org/release/community/roadmap/__;!!G_uCfscf7eWS!ccEx6zmuNrVADqtN50hO2N0k4Qs-A70nztAjMLu-JElnjhK5w84BpYC8CAINd6KihSxaS2rx_Lgpw6v6hKE$>
>
> I am thinking that if AD works so I don’t even need to do finite
> differencing Jacobian, or have it as another option.
>

Other people understand that better than I do.

  Thanks,

     Matt


> Best,
>
>
>
> -Ling
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!dvR7knTNgJjVsN8MbdkzqHYGMeFeJA5KRmWbLart8sNlv5MD6vaocv12fo_IltMmctrA04DuDQsTXfZqhc9B$  <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!dvR7knTNgJjVsN8MbdkzqHYGMeFeJA5KRmWbLart8sNlv5MD6vaocv12fo_IltMmctrA04DuDQsTXUFmc9QT$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250116/e1b21975/attachment.html>


More information about the petsc-users mailing list