Mercurial > repos > public > sbplib
changeset 657:b59345f905f0 feature/grids
Make noname.calculateErrors parallel
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 24 Oct 2017 16:32:00 +0200 |
parents | 38446922c32a |
children | 1201eb16557e |
files | +noname/calculateErrors.m |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/+noname/calculateErrors.m Tue Oct 24 11:36:53 2017 +0200 +++ b/+noname/calculateErrors.m Tue Oct 24 16:32:00 2017 +0200 @@ -5,22 +5,25 @@ % N are number of timesteps to use for each gird size % timeOpt are options for the timeStepper function e = calculateErrors(schemeFactory, T, m, N, errorFun, timeOpt) + %TODO: Ability to choose paralell or not assertType(schemeFactory, 'function_handle'); assertNumberOfArguments(schemeFactory, 1); assertScalar(T); assert(length(m) == length(N), 'Vectors m and N must have the same length'); assertType(errorFun, 'function_handle'); assertNumberOfArguments(errorFun, 2); - default_arg('timeOpt'); + default_arg('timeOpt', struct()); + e = []; - for i = 1:length(m) + parfor i = 1:length(m) done = timeTask('m = %3d ', m(i)); [discr, trueSolution] = schemeFactory(m(i)); - timeOpt.k = T/N(i); - ts = discr.getTimestepper(timeOpt); + timeOptTemp = timeOpt; + timeOptTemp.k = T/N(i); + ts = discr.getTimestepper(timeOptTemp); ts.stepTo(N(i), true); approxSolution = discr.getTimeSnapshot(ts);