Mercurial > repos > public > sbplib
comparison +time/Timestepper.m @ 1113:47e86b5270ad feature/timesteppers
Change name of property k to dt in time.Timestepper
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 10 Apr 2019 22:40:55 +0200 |
parents | a99f00896b8e |
children |
comparison
equal
deleted
inserted
replaced
1112:835c8fa456ec | 1113:47e86b5270ad |
---|---|
1 classdef Timestepper < handle | 1 classdef Timestepper < handle |
2 properties (Abstract) | 2 properties (Abstract) |
3 t | 3 t |
4 k % TBD: should this be a method instead? | 4 dt % TBD: should this be a method instead? |
5 n | 5 n |
6 end | 6 end |
7 | 7 |
8 methods (Abstract) | 8 methods (Abstract) |
9 % Returns the solution vector v at timestep t. | 9 % Returns the solution vector v at timestep t. |
79 v = obj.getV; | 79 v = obj.getV; |
80 t = obj.t; | 80 t = obj.t; |
81 end | 81 end |
82 | 82 |
83 function evolve_without_progress(obj, tend) | 83 function evolve_without_progress(obj, tend) |
84 while obj.t < tend - obj.k/2 | 84 while obj.t < tend - obj.dt/2 |
85 obj.step(); | 85 obj.step(); |
86 end | 86 end |
87 end | 87 end |
88 | 88 |
89 function evolve_with_progress(obj, tend) | 89 function evolve_with_progress(obj, tend) |
91 | 91 |
92 steps_to_update = 1; | 92 steps_to_update = 1; |
93 steps_since_update = 0; | 93 steps_since_update = 0; |
94 last_update = tic(); | 94 last_update = tic(); |
95 s = util.replace_string('',' %d %%',0); | 95 s = util.replace_string('',' %d %%',0); |
96 while obj.t < tend - obj.k/2 | 96 while obj.t < tend - obj.dt/2 |
97 obj.step(); | 97 obj.step(); |
98 | 98 |
99 steps_since_update = steps_since_update + 1; | 99 steps_since_update = steps_since_update + 1; |
100 | 100 |
101 if steps_since_update >= steps_to_update | 101 if steps_since_update >= steps_to_update |