rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
rb_test_projection_error.m
1 function test_err = rb_test_projection_error(model,detailed_data,reduced_data,M_test,...
2  savepath)
3 %function test_err = rb_test_projection_error(model,detailed_data,reduced_data,M_test,...
4 % savepath)
5 %
6 % function determining the test-projection-errors, i.e. L2([0,T],X)
7 % error for the given set of vectors `\mu`
8 % (columns in 'M_test') of the full simulation projected on the
9 % current RB space.
10 %
11 % parameters:
12 % M_test: matrix with column vectors of parameter tuples `\mu` for which the
13 % error between reduced and detailed simulation shall be computed.
14 % savepath: directory path where the detailed simulations shall be saved to
16 %
17 % optional fields of model:
18 %
19 % return values:
20 % test_err: vector of errors
21 
22 % Bernard Haasdonk 7.9.2011
23 
24 % import model specific methods
25 
26 nmus = size(M_test,2);
27 test_err = zeros(nmus,1);
28 
29 if isempty(savepath)
30  error('savepath must be provided in case of error as target value!');
31 end;
32 save_detailed_simulations(model, detailed_data, M_test, savepath);
33 W = model.get_inner_product_matrix(detailed_data);
34 RB = model.get_rb_from_detailed_data(detailed_data);
35 
36 parfor i = 1:nmus
37  fprintf('.');
38  tmodel = model;
39 
40  tmodel = tmodel.set_mu(tmodel, M_test(:,i));
41 % rb_sim_data = rb_simulation(tmodel,reduced_data);
42  sim_data = load_detailed_simulation(i, ...
43  savepath,...
44  tmodel);
45  X = tmodel.get_dofs_from_sim_data(sim_data);
46  Xproj_err = X- RB * ((RB' * W) * X);
47  err = sum(sum((W * Xproj_err).*Xproj_err));
48 % keyboard;
49 % err = errs(end);
50 % disp('warning, check monotonicity in errs!!!');
51  test_err(i) = err;
52 % if (i==2) & (mod(size(detailed_data.RB,2),30) == 0)
53 % save(['errs',num2str(size(detailed_data.RB,2))],'errs');
54 % end;
55 end;
56 
57 disp(test_err');
58 
function [ sim_data , tictoc ] = load_detailed_simulation(m, savepath, params)
load single trajectory of previously saved results.
function save_detailed_simulations(model, model_data, M, savepath)
perform loop over detailed simulations and save results or check consistency with existing saved resu...