Hi Lawrence, Thank you very much for your answer. Using nonlinear solvers indeed improved a lot the running speed! I tried to profile my code but I get the following error concerning the timed_stage module: Traceback (most recent call last): File "3D_NL.py", line 9, in <module> from pyop2.profiling import timed_stage ImportError: cannot import name timed_stage I found online something called "timed_region", would that be the same as timed_stage ? Thanks, Floriane ________________________________ De : firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> de la part de Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> Envoyé : jeudi 7 juillet 2016 16:58:52 À : firedrake@imperial.ac.uk Objet : Re: [firedrake] optimisation of the running time Hi Floriane, apologies for the slow reply. On 21/06/16 16:03, Floriane Gidel [RPG] wrote:
Dear all,
I would like some advice to decrease the running time in my code 3D_NL.py . Details are given in the attached pdf and below is a quick summary:
...
At the moment, the equations are solved in a small domain with resolution 0.1, but it's running very slowly. Running in parallel does not improve it since the number of nodes is too small.
Is there another way to increase the simulation speed? Maybe by changing the iteration criteria in the solver ?
My first suggestion, looking at the code would be to replace the direct calls to solve in the timestepping loop, for example: solve(WF1 == 0, w1) by a reusable solver that you can call again and again. So, rather than having: while t < Tend: ... solve(WF1 == 0, w1) ... You do: wf1_problem = NonlinearVariationalProblem(WF1, w1) wf1_solver = NonlinearVariationalSolver(wf1_problem) while t < Tend: ... wf1_solver.solve() ... This should reduce the amount of symbolic processing and other things significantly. Once you've done that, you should try profiling your code. To get some breakdowns of the time you can import some convenience timers from PyOP2: from pyop2.profiling import timed_stage For the different "stages" in your code, e.g. the different solvers, or the visualisation output, you can use these as a context manager to agglomerate timings: while t < Tend: ... with timed_stage("WF1 solve"): wf1_solver.solve() ... Now, you can run your program with: python simulation.py -log_view And you will get a breakdown of timings split apart by stages. We can look at this and decide where to go from there. Cheers, Lawrence