Mercurial > repos > public > sbplib
annotate +noname/animate.m @ 20:c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Tue, 22 Sep 2015 17:35:58 +0200 |
| parents | 48b6fb693025 |
| children | cca09cc5121d |
| 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 | |
| 13 default_arg('Tend',5*60); | |
| 14 default_arg('time_modifier',1); | |
| 15 default_arg('time_method',[]); | |
| 16 | |
| 17 | |
| 18 fprintf('Animating: %s\n',discretization.name); | |
| 19 fprintf('Tend : %.2f\n',Tend); | |
| 20 fprintf('order : %d\n',discretization.order); | |
| 21 fprintf('m : %d\n',size(discretization)); | |
| 22 | |
| 23 fprintf('Creating time discretization'); | |
| 24 tic | |
| 25 ts = discretization.getTimestepper(time_method); | |
| 26 fprintf(' - done %fs\n', toc()) | |
| 27 | |
|
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
|
28 [update, figure_handle] = discretization.setupPlot('animation'); |
| 0 | 29 |
| 30 if makemovies | |
| 31 save_frame = anim.setup_fig_mov(figure_handle,dirname); | |
| 32 end | |
| 33 | |
| 34 | |
| 35 % Initialize loop | |
| 36 str = ''; | |
| 37 % Loop function | |
| 38 function next_t = G(next_t) | |
| 39 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
|
40 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
|
41 update(sol); |
| 0 | 42 % waitforbuttonpress |
| 43 if makemovies | |
| 44 save_frame(); | |
| 45 end | |
| 46 % pause(0.1) | |
| 47 str = util.replace_string(str,'t = %.2f',ts.t); | |
| 48 | |
| 49 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
|
50 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
|
51 update(sol); |
| 0 | 52 |
| 53 fprintf('Using time step k = %.6f\n',ts.k) | |
| 54 fprintf('System size: %d\n',size(discretization)) | |
| 55 waitforbuttonpress | |
| 56 anim.animate(@G,0,Tend,time_modifier) | |
| 57 str = util.replace_string(str,''); | |
| 58 | |
| 59 % if makemovies | |
| 60 % fprintf('Generating movies...\n') | |
| 61 % system(sprintf('bash make_movie.sh %s',dirname)); | |
| 62 % end | |
| 63 end |
