comparison +noname/calculateSolution.m @ 25:791decafe6e4

Made calculateSolution save the discretization instead of a handle to contructor.
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 25 Sep 2015 14:51:18 +0200
parents c7efff913935
children ddfb98209aa2
comparison
equal deleted inserted replaced
24:986e3efd8543 25:791decafe6e4
42 k_max = discr.getTimestep(method); 42 k_max = discr.getTimestep(method);
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 snapshot = discr.getTimeSnapshot(0); 46 snapshot = discr.getTimeSnapshot(0);
47 saveToFile(sf, method, order(i), m(j),T(1), snapshot, NaN, NaN, discrHand); 47 saveToFile(sf, method, order(i), m(j),T(1), snapshot, NaN, NaN, discr);
48 T(1) = []; 48 T(1) = [];
49 end 49 end
50 50
51 % T now contains all the times we need to step to, 51 % T now contains all the times we need to step to,
52 % if T contained 0 it has now been removed. 52 % if T contained 0 it has now been removed.
61 fprintf('[order = %-*d, m = %-*d, T = %-*d]: ',orderWidth,order(i),mWidth,m(j),TWidth,T(l)); 61 fprintf('[order = %-*d, m = %-*d, T = %-*d]: ',orderWidth,order(i),mWidth,m(j),TWidth,T(l));
62 clock_start = tic(); 62 clock_start = tic();
63 ts.stepN(end_step-ts.n,true); 63 ts.stepN(end_step-ts.n,true);
64 runtime = runtime + toc(clock_start); 64 runtime = runtime + toc(clock_start);
65 snapshot = discr.getTimeSnapshot(ts); 65 snapshot = discr.getTimeSnapshot(ts);
66 saveToFile(sf, method, order(i), m(j),T(l), snapshot, runtime, k, discrHand); 66 saveToFile(sf, method, order(i), m(j),T(l), snapshot, runtime, k, discr);
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)
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 snapshot = discr.getTimeSnapshot(ts); 78 snapshot = discr.getTimeSnapshot(ts);
79 saveToFile(sf, method, order(i), m(j),T(l), snapshot, runtime, k, discrHand); 79 saveToFile(sf, method, order(i), m(j),T(l), snapshot, runtime, k, discr);
80 fprintf('Done! (%.3fs)\n',runtime); 80 fprintf('Done! (%.3fs)\n',runtime);
81 end 81 end
82 82
83 end 83 end
84 84
85 end 85 end
86 end 86 end
87 end 87 end
88 88
89 89
90 function saveToFile(sf, method, order, m, T, snapshot, runtime, k, discrHand) 90 function saveToFile(sf, method, order, m, T, snapshot, runtime, k, discr)
91 key.method = method; 91 key.method = method;
92 key.order = order; 92 key.order = order;
93 key.m = m; 93 key.m = m;
94 key.T = T; 94 key.T = T;
95 95
96 entry.repr = snapshot; 96 entry.repr = snapshot;
97 entry.runtime = runtime; 97 entry.runtime = runtime;
98 entry.k = k; 98 entry.k = k;
99 entry.discrHand = discrHand; 99 entry.discr = discr;
100 100
101 sf.store(key,entry); 101 sf.store(key,entry);
102 end 102 end