Kev,

I've done some layman's benchmarking of the individual "steps" (setup, assembly, solve, ...) in my current version of the code. It looks as if the assembly takes several orders of magnitude (~100 at least) longer than the solving part.

My question is now: What is the best strategy to speed up assembly, is there any experience with this? I've read different approaches and am confused what's promising for small-scale problems. So far I'm considering:

1) Using a matrix-free approach rather than PETSc - this seems to be a win in most cases, would however consider  rewriting large parts of the code and I am not sure if I will gain a lot given my small system size.

2) Only assemble the Jacobian every few steps, but the residual in every step. This is probably easier to implement. I know from experience with my problem that I pretty quickly land in a situation where I need only one or two Newton steps to find the solution to my nonlinear equation, so there saving will be small at best.

Like Bruno, it seems rather unlikely to me that assembly would take 100x times longer than other things, and I would suggest you use something like TimerOutput to time individual sections to narrow down where the issue lies.

Beyond this, only updating the Jacobian is indeed a fairly usual strategy. One can of course implement this by hand, but it's quite cumbersome to implement optimal algorithms to determine when updating is necessary, and I would encourage you to take a look at step-77 to see how one can solve nonlinear problems efficiently through interfaces to advanced libraries such as SUNDIALS:
  https://dealii.org/developer/doxygen/deal.II/step_77.html

I don't remember if KINSOL has ways to solve a sequence of nonlinear system, re-using the Jacobian between systems. But if it does not, you can always just store a pointer to the last Jacobian matrix and whenever you start solving a linear system for the first time, copy the stored matrix over.

In any case, I think the first step should be to look at (i) whether assembly really takes that long for you, (ii) understand why it takes that long. If step-77 is any indication, then assembling the Jacobian should really not take that much longer than actually solving linear systems.

Best
 W.


--
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 [email protected]
                           www: http://www.math.colostate.edu/~bangerth/


--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/d151778c-297c-834d-88ed-8bcadda95298%40colostate.edu.

Reply via email to