changeset 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 61367018c46f
children 1770689d6c31
files +noname/calculateSolution.m +noname/convergence.m
diffstat 2 files changed, 16 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
diff -r 61367018c46f -r c6eb3af205c0 +noname/calculateSolution.m
--- a/+noname/calculateSolution.m	Tue Oct 06 09:48:46 2015 +0200
+++ b/+noname/calculateSolution.m	Tue Oct 06 09:51:52 2015 +0200
@@ -22,16 +22,6 @@
     % Make sure times are sorted
     T = sort(T);
 
-    % Find out if times to be calulated are integer multiples of the smallest one.
-    time_multiples = T/T(1);
-    is_int_multiples = all(time_multiples == int64(time_multiples));
-
-    if is_int_multiples
-        fprintf('Calculating time series in increments\n');
-    else
-        fprintf('Restarting for each time in timeseries\n');
-    end
-
 
     orderWidth = findFieldWidth('%d',order);
     mWidth = findFieldWidth('%d',m);
@@ -49,6 +39,17 @@
                 T(1) = [];
             end
 
+            % Find out if times to be calulated are integer multiples of the smallest one.
+            time_multiples = T/T(1);
+
+            is_int_multiples = all(time_multiples == int64(time_multiples));
+
+            if is_int_multiples
+                fprintf('Calculating time series in increments\n');
+            else
+                fprintf('Restarting for each time in timeseries\n');
+            end
+
             % T now contains all the times we need to step to,
             % if T contained 0 it has now been removed.
 
diff -r 61367018c46f -r c6eb3af205c0 +noname/convergence.m
--- a/+noname/convergence.m	Tue Oct 06 09:48:46 2015 +0200
+++ b/+noname/convergence.m	Tue Oct 06 09:51:52 2015 +0200
@@ -1,14 +1,9 @@
 % Reference is either a key or a function handle
-function [q, e, h] = convergence(filename, errorFunc, reference, method, order, m, T)
+function [q, e, h, runtime] = convergence(filename, errorFunc, reference, method, order, m, T)
     default_arg('errorFunc', @scheme.error1d);
 
     sf = SolutionFile(filename);
 
-    analytical_ref = isa(reference,'function_handle');
-    if ~analytical_ref
-        reference = sf.get(reference);
-    end
-
 
     % Generate convergence, error, and efficiency plots for each search key with more than one entry.
     for i = 1:length(m)
@@ -20,6 +15,7 @@
         entry = sf.get(key);
 
         [e(i),h(i)] = errorForEntry(key, entry, errorFunc, reference,T);
+        runtime(i) = entry.runtime;
 
     end
     q = convergence(e,h);
@@ -42,6 +38,9 @@
         x_ref = reference.x;
 
         [~,I] = ismember(x,x_ref,'rows');
+        if any(I == 0)
+            error('Solution and reference solution seem to be on different grids.');
+        end
         v_ref = reference.v(I);
     end