Mercurial > repos > public > sbplib
annotate +noname/animate.m @ 57:9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Thu, 12 Nov 2015 17:31:33 -0800 |
| parents | cca09cc5121d |
| children | f87003695677 |
| 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); |
| 0 | 49 % waitforbuttonpress |
| 50 if makemovies | |
| 51 save_frame(); | |
| 52 end | |
| 53 % 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
|
54 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
|
55 |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
56 if do_pause |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
57 pause |
|
9a647dcccbdd
Added pausing option to noname.animate. Added characteristic bc to Euler1d.
Jonatan Werpers <jonatan@werpers.com>
parents:
53
diff
changeset
|
58 end |
| 0 | 59 |
| 60 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
|
61 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
|
62 update(sol); |
| 0 | 63 |
| 64 fprintf('Using time step k = %.6f\n',ts.k) | |
| 65 fprintf('System size: %d\n',size(discretization)) | |
| 66 waitforbuttonpress | |
| 67 anim.animate(@G,0,Tend,time_modifier) | |
| 68 str = util.replace_string(str,''); | |
| 69 | |
| 70 % if makemovies | |
| 71 % fprintf('Generating movies...\n') | |
| 72 % system(sprintf('bash make_movie.sh %s',dirname)); | |
| 73 % end | |
| 74 end |
