Mercurial > repos > public > sbplib
comparison +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 |
comparison
equal
deleted
inserted
replaced
| 19:1644d000c304 | 20:c7efff913935 |
|---|---|
| 23 fprintf('Creating time discretization'); | 23 fprintf('Creating time discretization'); |
| 24 tic | 24 tic |
| 25 ts = discretization.getTimestepper(time_method); | 25 ts = discretization.getTimestepper(time_method); |
| 26 fprintf(' - done %fs\n', toc()) | 26 fprintf(' - done %fs\n', toc()) |
| 27 | 27 |
| 28 [update, figure_handle] = discretization.setupPlot(); | 28 [update, figure_handle] = discretization.setupPlot('animation'); |
| 29 | 29 |
| 30 if makemovies | 30 if makemovies |
| 31 save_frame = anim.setup_fig_mov(figure_handle,dirname); | 31 save_frame = anim.setup_fig_mov(figure_handle,dirname); |
| 32 end | 32 end |
| 33 | 33 |
| 35 % Initialize loop | 35 % Initialize loop |
| 36 str = ''; | 36 str = ''; |
| 37 % Loop function | 37 % Loop function |
| 38 function next_t = G(next_t) | 38 function next_t = G(next_t) |
| 39 ts.evolve(next_t); | 39 ts.evolve(next_t); |
| 40 update(ts); | 40 sol = discretization.getTimeSnapshot(ts); |
| 41 update(sol); | |
| 41 % waitforbuttonpress | 42 % waitforbuttonpress |
| 42 if makemovies | 43 if makemovies |
| 43 save_frame(); | 44 save_frame(); |
| 44 end | 45 end |
| 45 % pause(0.1) | 46 % pause(0.1) |
| 46 str = util.replace_string(str,'t = %.2f',ts.t); | 47 str = util.replace_string(str,'t = %.2f',ts.t); |
| 47 | 48 |
| 48 end | 49 end |
| 49 update(ts); | 50 sol = discretization.getTimeSnapshot(0); |
| 51 update(sol); | |
| 50 | 52 |
| 51 fprintf('Using time step k = %.6f\n',ts.k) | 53 fprintf('Using time step k = %.6f\n',ts.k) |
| 52 fprintf('System size: %d\n',size(discretization)) | 54 fprintf('System size: %d\n',size(discretization)) |
| 53 waitforbuttonpress | 55 waitforbuttonpress |
| 54 anim.animate(@G,0,Tend,time_modifier) | 56 anim.animate(@G,0,Tend,time_modifier) |
