Mercurial > repos > public > sbplib
annotate +noname/animate.m @ 69:f87003695677
Moved drawno out of plot update functions for huge performance boost.
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Mon, 23 Nov 2015 13:54:01 +0100 |
| parents | 9a647dcccbdd |
| children | 1edee9e1ea41 |
| rev | line source |
|---|---|
| 0 | 1 % animate(dirname,discretization,Tend, time_modifier,time_method) |
| 2 % | |
| 3 % Example: | |
| 4 % animate('',discr,tend) | |
| 5 % animate('my_mov',discr,tend,time_mod,time_method) | |
| 6 | |
| 7 function hand = animate(dirname,discretization,Tend, time_modifier,time_method) | |
| 8 makemovies = ~strcmp(dirname,''); | |
| 9 if makemovies | |
| 10 dirname = ['mov/' dirname]; | |
| 11 end | |
| 12 | |
|
53
cca09cc5121d
Changed default animation time to infinity.
Jonatan Werpers <jonatan@werpers.com>
parents:
20
diff
changeset
|
13 default_arg('Tend',Inf); |
| 0 | 14 default_arg('time_modifier',1); |
| 15 default_arg('time_method',[]); | |
| 16 | |
|
57
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
17 if time_modifier < 0 |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
18 do_pause = true; |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
19 time_modifier = -time_modifier; |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
20 else |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
21 do_pause = false; |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
22 end |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
23 |
| 0 | 24 |
| 25 fprintf('Animating: %s\n',discretization.name); | |
| 26 fprintf('Tend : %.2f\n',Tend); | |
| 27 fprintf('order : %d\n',discretization.order); | |
| 28 fprintf('m : %d\n',size(discretization)); | |
| 29 | |
| 30 fprintf('Creating time discretization'); | |
| 31 tic | |
| 32 ts = discretization.getTimestepper(time_method); | |
| 33 fprintf(' - done %fs\n', toc()) | |
| 34 | |
|
20
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
35 [update, figure_handle] = discretization.setupPlot('animation'); |
| 0 | 36 |
| 37 if makemovies | |
| 38 save_frame = anim.setup_fig_mov(figure_handle,dirname); | |
| 39 end | |
| 40 | |
| 41 | |
| 42 % Initialize loop | |
| 43 str = ''; | |
| 44 % Loop function | |
| 45 function next_t = G(next_t) | |
| 46 ts.evolve(next_t); | |
|
20
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
47 sol = discretization.getTimeSnapshot(ts); |
|
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
48 update(sol); |
|
69
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
57
diff
changeset
|
49 drawnow |
| 0 | 50 % waitforbuttonpress |
| 51 if makemovies | |
| 52 save_frame(); | |
| 53 end | |
| 54 % pause(0.1) | |
|
57
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
55 str = util.replace_string(str,'t = %.5f',ts.t); |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
56 |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
57 if do_pause |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
58 pause |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
59 end |
| 0 | 60 |
| 61 end | |
|
20
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
62 sol = discretization.getTimeSnapshot(0); |
|
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
63 update(sol); |
| 0 | 64 |
| 65 fprintf('Using time step k = %.6f\n',ts.k) | |
| 66 fprintf('System size: %d\n',size(discretization)) | |
|
69
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
57
diff
changeset
|
67 % waitforbuttonpress |
| 0 | 68 anim.animate(@G,0,Tend,time_modifier) |
| 69 str = util.replace_string(str,''); | |
| 70 | |
| 71 % if makemovies | |
| 72 % fprintf('Generating movies...\n') | |
| 73 % system(sprintf('bash make_movie.sh %s',dirname)); | |
| 74 % end | |
| 75 end |
