Mercurial > repos > public > sbplib
comparison +noname/convergence.m @ 36:c6eb3af205c0
Better error handeling in noname.convergence. Better handeling of T=0 in noname.calculateSolution
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 06 Oct 2015 09:51:52 +0200 |
parents | ddfb98209aa2 |
children | 7bb2ef637142 |
comparison
equal
deleted
inserted
replaced
35:61367018c46f | 36:c6eb3af205c0 |
---|---|
1 % Reference is either a key or a function handle | 1 % Reference is either a key or a function handle |
2 function [q, e, h] = convergence(filename, errorFunc, reference, method, order, m, T) | 2 function [q, e, h, runtime] = convergence(filename, errorFunc, reference, method, order, m, T) |
3 default_arg('errorFunc', @scheme.error1d); | 3 default_arg('errorFunc', @scheme.error1d); |
4 | 4 |
5 sf = SolutionFile(filename); | 5 sf = SolutionFile(filename); |
6 | |
7 analytical_ref = isa(reference,'function_handle'); | |
8 if ~analytical_ref | |
9 reference = sf.get(reference); | |
10 end | |
11 | 6 |
12 | 7 |
13 % Generate convergence, error, and efficiency plots for each search key with more than one entry. | 8 % Generate convergence, error, and efficiency plots for each search key with more than one entry. |
14 for i = 1:length(m) | 9 for i = 1:length(m) |
15 key.method = method; | 10 key.method = method; |
18 key.T = T; | 13 key.T = T; |
19 | 14 |
20 entry = sf.get(key); | 15 entry = sf.get(key); |
21 | 16 |
22 [e(i),h(i)] = errorForEntry(key, entry, errorFunc, reference,T); | 17 [e(i),h(i)] = errorForEntry(key, entry, errorFunc, reference,T); |
18 runtime(i) = entry.runtime; | |
23 | 19 |
24 end | 20 end |
25 q = convergence(e,h); | 21 q = convergence(e,h); |
26 end | 22 end |
27 | 23 |
40 % Downsample the reference solution | 36 % Downsample the reference solution |
41 x = v_repr.x; | 37 x = v_repr.x; |
42 x_ref = reference.x; | 38 x_ref = reference.x; |
43 | 39 |
44 [~,I] = ismember(x,x_ref,'rows'); | 40 [~,I] = ismember(x,x_ref,'rows'); |
41 if any(I == 0) | |
42 error('Solution and reference solution seem to be on different grids.'); | |
43 end | |
45 v_ref = reference.v(I); | 44 v_ref = reference.v(I); |
46 end | 45 end |
47 | 46 |
48 e = errorFunc(discr,v, v_ref); | 47 e = errorFunc(discr,v, v_ref); |
49 h = discr.h; | 48 h = discr.h; |