Mercurial > repos > public > sbplib
changeset 933:34b3d092a4d0 feature/timesteppers
Add methods timePoints and quadWeights to Rungekutta class.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Mon, 03 Dec 2018 16:49:43 -0800 |
parents | 3860dad28239 |
children | 7a5e770974ed |
files | +time/Rungekutta.m |
diffstat | 1 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/+time/Rungekutta.m Mon Dec 03 16:33:27 2018 -0800 +++ b/+time/Rungekutta.m Mon Dec 03 16:49:43 2018 -0800 @@ -60,5 +60,28 @@ obj.t = obj.t + obj.dt; obj.n = obj.n + 1; end + + % Returns a vector of time points, including substage points, + % in the time interval [t0, tEnd]. + % The time-step obj.dt is assumed to be aligned with [t0, tEnd] already. + function tvec = timePoints(obj, t0, tEnd) + N = round( (tEnd-t0)/obj.dt ); + tvec = zeros(N*obj.s, 1); + s = obj.coeffs.s; + c = obj.coeffs.c; + for i = 1:N + ind = (i-1)*s+1 : i*s; + tvec(ind) = ((i-1) + c')*obj.dt; + end + end + + % Returns a vector of quadrature weights corresponding to grid points + % in time interval [t0, tEnd], substage points included. + % The time-step obj.dt is assumed to be aligned with [t0, tEnd] already. + function weights = quadWeights(obj, t0, tEnd) + N = round( (tEnd-t0)/obj.dt ); + b = obj.coeffs.b; + weights = repmat(b', N, 1); + end end end \ No newline at end of file