Mercurial > repos > public > sbplib
comparison +noname/calculateSolution.m @ 19:1644d000c304
Fixed bug in SolutionsFile.m. Updated calculateSolution to also save a function handle to the Discr constructor.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Sep 2015 17:10:51 +0200 |
parents | 30ae48efc7ae |
children | c7efff913935 |
comparison
equal
deleted
inserted
replaced
18:4d8068cb5c65 | 19:1644d000c304 |
---|---|
43 | 43 |
44 % Do we want to to save the initial conditions? | 44 % Do we want to to save the initial conditions? |
45 if T(1) == 0 | 45 if T(1) == 0 |
46 v = discr.v0; | 46 v = discr.v0; |
47 t = 0; | 47 t = 0; |
48 saveToFile(sf, method, order(i), m(j),T(1), v, t, NaN, NaN); | 48 saveToFile(sf, method, order(i), m(j),T(1), v, t, NaN, NaN, discrHand); |
49 T(1) = []; | 49 T(1) = []; |
50 end | 50 end |
51 | 51 |
52 % T now contains all the times we need to step to, | 52 % T now contains all the times we need to step to, |
53 % if T contained 0 it has now been removed. | 53 % if T contained 0 it has now been removed. |
61 end_step = N * time_multiples(l); | 61 end_step = N * time_multiples(l); |
62 fprintf('[order = %-*d, m = %-*d, T = %-*d]: ',orderWidth,order(i),mWidth,m(j),TWidth,T(l)); | 62 fprintf('[order = %-*d, m = %-*d, T = %-*d]: ',orderWidth,order(i),mWidth,m(j),TWidth,T(l)); |
63 clock_start = tic(); | 63 clock_start = tic(); |
64 [v,t] = ts.stepN(end_step-ts.n,true); | 64 [v,t] = ts.stepN(end_step-ts.n,true); |
65 runtime = runtime + toc(clock_start); | 65 runtime = runtime + toc(clock_start); |
66 saveToFile(sf, method, order(i), m(j),T(l), v, t, runtime, k); | 66 saveToFile(sf, method, order(i), m(j),T(l), v, t, runtime, k, discrHand); |
67 fprintf('Done! (%.3fs)\n',runtime); | 67 fprintf('Done! (%.3fs)\n',runtime); |
68 end | 68 end |
69 else | 69 else |
70 % Times are not interger multiples, we have to start from 0 every time. | 70 % Times are not interger multiples, we have to start from 0 every time. |
71 for l = 1:length(T) | 71 for l = 1:length(T) |
73 ts = discr.getTimestepper(method,k); | 73 ts = discr.getTimestepper(method,k); |
74 fprintf('[order = %-*d, m = %-*d, T = %-*d]: ',orderWidth,order(i),mWidth,m(j),TWidth,T(l)); | 74 fprintf('[order = %-*d, m = %-*d, T = %-*d]: ',orderWidth,order(i),mWidth,m(j),TWidth,T(l)); |
75 clock_start = tic(); | 75 clock_start = tic(); |
76 [v,t] = ts.stepN(N-ts.n,true); | 76 [v,t] = ts.stepN(N-ts.n,true); |
77 runtime = toc(clock_start); | 77 runtime = toc(clock_start); |
78 saveToFile(sf, method, order(i), m(j),T(l), v, t, runtime, k); | 78 saveToFile(sf, method, order(i), m(j),T(l), v, t, runtime, k, discrHand); |
79 fprintf('Done! (%.3fs)\n',runtime); | 79 fprintf('Done! (%.3fs)\n',runtime); |
80 end | 80 end |
81 | 81 |
82 end | 82 end |
83 | 83 |
84 end | 84 end |
85 end | 85 end |
86 end | 86 end |
87 | 87 |
88 | 88 |
89 function saveToFile(sf, method, order, m, T, v, t, runtime, k) | 89 function saveToFile(sf, method, order, m, T, v, t, runtime, k, discrHand) |
90 key.method = method; | 90 key.method = method; |
91 key.order = order; | 91 key.order = order; |
92 key.m = m; | 92 key.m = m; |
93 key.T = T; | 93 key.T = T; |
94 | 94 |
95 entry.v = v; | 95 entry.v = v; |
96 entry.t = t; | 96 entry.t = t; |
97 entry.runtime = runtime; | 97 entry.runtime = runtime; |
98 entry.k = k; | 98 entry.k = k; |
99 entry.discrHand = discrHand; | |
99 | 100 |
100 sf.store(key,entry); | 101 sf.store(key,entry); |
101 end | 102 end |