From 3eab77dfcd599450696a880ef6dc9677c9ad4e45 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Tue, 17 Oct 2023 16:00:06 -0400 Subject: [PATCH] Update the tutorial --- docs/src/tutorials/advanced.md | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/docs/src/tutorials/advanced.md b/docs/src/tutorials/advanced.md index 01a337e12..2613a5e3b 100644 --- a/docs/src/tutorials/advanced.md +++ b/docs/src/tutorials/advanced.md @@ -209,8 +209,7 @@ function incompletelu(W, du, u, p, t, newW, Plprev, Prprev, solverdata) end @btime solve(prob_brusselator_2d_sparse, - NewtonRaphson(linsolve = KrylovJL_GMRES(), precs = incompletelu, - concrete_jac = true)); + NewtonRaphson(linsolve = KrylovJL_GMRES(), precs = incompletelu, concrete_jac = true)); nothing # hide ``` @@ -275,28 +274,3 @@ nothing # hide For more information on the preconditioner interface, see the [linear solver documentation](https://docs.sciml.ai/LinearSolve/stable/basics/Preconditioners/). - -## Speed up Jacobian computation with sparsity exploitation and matrix coloring - -To cut down the of Jacobian building overhead, we can choose to exploit the sparsity pattern and deploy matrix coloring during Jacobian construction. With NonlinearSolve.jl, we can simply use `autodiff=AutoSparseForwardDiff()` to automatically exploit the sparsity pattern of Jacobian matrices: - -```@example ill_conditioned_nlprob -@btime solve(prob_brusselator_2d, - NewtonRaphson(linsolve = KrylovJL_GMRES(), precs = incompletelu, concrete_jac = true, - autodiff = AutoSparseForwardDiff())); -nothing # hide -``` - -To setup matrix coloring for the jacobian sparsity pattern, we can simply get the coloring vector by using [ArrayInterface.jl](https://github.com/JuliaArrays/ArrayInterface.jl) for the sparsity pattern of `jac_prototype`: - -```@example ill_conditioned_nlprob -using ArrayInterface -colorvec = ArrayInterface.matrix_colors(jac_sparsity) -ff = NonlinearFunction(brusselator_2d_loop; jac_prototype = float.(jac_sparsity), colorvec) -prob_brusselator_2d_sparse = NonlinearProblem(ff, u0, p) - -@btime solve(prob_brusselator_2d_sparse, - NewtonRaphson(linsolve = KrylovJL_GMRES(), precs = incompletelu, concrete_jac = true, - autodiff = AutoSparseForwardDiff())); -nothing # hide -```