Mercurial > repos > public > sbplib
changeset 2:bce9e28c1e26
Added a cfl paramater to getTimestepper in Discretization. Added function to get cfl value for a Discr.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 18 Sep 2015 12:50:52 +0200 |
parents | 5ae4f23d9130 |
children | 5205251db8c3 |
files | +noname/Discretization.m +noname/testCfl.m |
diffstat | 2 files changed, 33 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/+noname/Discretization.m Thu Sep 17 19:19:58 2015 +0200 +++ b/+noname/Discretization.m Fri Sep 18 12:50:52 2015 +0200 @@ -18,7 +18,7 @@ % the appropriate timestepper. It should also provide a default value. % time_align is a time that the timesteps should align with so that for some % integer number of timesteps we end up exactly on time_align - ts = getTimestepper(obj,method,time_align) %% ??? + ts = getTimestepper(obj,method,time_align,cfl) %% ??? % Sets up movie recording to a given file. % saveFrame is a function_handle with no inputs that records the current state
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/+noname/testCfl.m Fri Sep 18 12:50:52 2015 +0200 @@ -0,0 +1,32 @@ +function testCfl(discr, timestepper_method, T, alpha0, tol,threshold) + default_arg('tol',0.00005); + default_arg('threshold',1e2); + + alpha0(2) = alpha0(1)+2*(alpha0(2)-alpha0(1)); + + while( (alpha0(2)-alpha0(1))/alpha0(1) > tol) + alpha = mean(alpha0); + + ts = discr.getTimestepper(timestepper_method,[],alpha); + + warning('off','all') + ts.evolve(T,true); + warning('on','all') + + [v,t] = ts.getV(); + + max_val = max(v); + + if isnan(max_val) || max_val == Inf || max_val > threshold + alpha0(2) = alpha; + else + alpha0(1) = alpha; + end + + fprintf('[%.3e,%.3e]: a = %.3e, max= %.2e\n',alpha0(1),alpha0(2), alpha,max_val); + + end + + fprintf('T = %-3d dof = %-4d order = %d: clf = %.4e\n',T, discr.size(), discr.order, alpha0(1)); + +end \ No newline at end of file