Mercurial > repos > public > sbplib
comparison +noname/animate.m @ 886:8894e9c49e40 feature/timesteppers
Merge with default for latest changes
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 15 Nov 2018 16:36:21 -0800 |
parents | 082c7bf3192e |
children | c9147e05d228 |
comparison
equal
deleted
inserted
replaced
816:b5e5b195da1e | 886:8894e9c49e40 |
---|---|
1 % hand = noname.animate(discretization, time_modifier, Tend, dirname, opt) | 1 % noname.animate(discretization, time_modifier, Tend, dirname, opt) |
2 % | 2 % |
3 % Example: | 3 % Example: |
4 % noname.animate(discr,timemodifier,tend) | 4 % noname.animate(discr,timemodifier,tend) |
5 % noname.animate(discr,1, [tstart tend],'my_mov', opt) | 5 % noname.animate(discr,1, [tstart tend],'my_mov', opt) |
6 | 6 |
7 function hand = animate(discretization, time_modifier, Tend, dirname, opt) | 7 function animate(discretization, time_modifier, Tend, dirname, opt) |
8 default_arg('time_modifier',1); | 8 default_arg('time_modifier', 1); |
9 default_arg('Tend', Inf); | 9 default_arg('Tend', Inf); |
10 default_arg('dirname',''); | 10 default_arg('dirname', ''); |
11 default_arg('opt', []); | 11 |
12 optDefault.plotType = 'animation'; | |
13 optDefault.time = []; | |
14 | |
15 default_struct('opt', optDefault); | |
12 | 16 |
13 | 17 |
14 if time_modifier < 0 | 18 if time_modifier < 0 |
15 do_pause = true; | 19 do_pause = true; |
16 time_modifier = -time_modifier; | 20 time_modifier = -time_modifier; |
32 fprintf('Animating: %s\n',discretization.name); | 36 fprintf('Animating: %s\n',discretization.name); |
33 fprintf('order : %d\n',discretization.order); | 37 fprintf('order : %d\n',discretization.order); |
34 fprintf('m : %d\n',size(discretization)); | 38 fprintf('m : %d\n',size(discretization)); |
35 | 39 |
36 | 40 |
37 ts = discretization.getTimestepper(opt); | 41 ts = discretization.getTimestepper(opt.time); |
38 | 42 |
39 if numel(Tend) == 2 | 43 if numel(Tend) == 2 |
40 Tstart = Tend(1); | 44 Tstart = Tend(1); |
41 Tend = Tend(2); | 45 Tend = Tend(2); |
42 | 46 |
48 else | 52 else |
49 start_solution = discretization.getTimeSnapshot(0); | 53 start_solution = discretization.getTimeSnapshot(0); |
50 Tstart = start_solution.t; | 54 Tstart = start_solution.t; |
51 end | 55 end |
52 | 56 |
53 [update, figure_handle] = discretization.setupPlot('animation'); | 57 [update, figure_handle] = discretization.setupPlot(opt.plotType); |
54 if makemovies | 58 if makemovies |
55 save_frame = anim.setup_fig_mov(figure_handle,dirname); | 59 save_frame = anim.setup_fig_mov(figure_handle,dirname); |
56 end | 60 end |
57 | 61 |
58 % Initialize loop | 62 % Initialize loop |
81 | 85 |
82 if ~do_step | 86 if ~do_step |
83 pause | 87 pause |
84 anim.animate(@G, Tstart, Tend, time_modifier); | 88 anim.animate(@G, Tstart, Tend, time_modifier); |
85 else | 89 else |
86 while true | 90 pause |
91 while ts.t < Tend | |
87 ts.step(); | 92 ts.step(); |
88 sol = discretization.getTimeSnapshot(ts); | 93 sol = discretization.getTimeSnapshot(ts); |
89 update(sol); | 94 update(sol); |
90 drawnow | 95 drawnow |
91 | 96 |