rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
test_ei.m
Go to the documentation of this file.
1 % small script testing the empirical interpolation
2 %
3 % detailed_data is loaded and single large timestep from 0 to T is
4 % performed. The linear and nonlinear simulation are opened in the
5 % gui for comparison and adjusting the parameters
6 
7 % Bernard Haasdonk 31.5.2007
8 
9 
10 load demo_nonlin_evol_detailed_data3
11 params.nt = 1;
12 params.dt=params.T;
13 params.k = 0; % deactivate implicit contribution
14 params.N = size(detailed_data.RB,2);
15 %params.M = size(detailed_data.QM{1},2);
16 params.M = 100;
17 paramslin = params;
18 paramslin.rb_problem_type = 'lin_evol';
19 
20 % plot both linear and nonlinear simulation result: should be the same
21 demo_rb_gui(detailed_data,[],params,'Nonlinear simulation');
22 demo_rb_gui(detailed_data,[],paramslin,'Linear simulation');
23 
24 % plot details on nonlinear evolution:
25 
26 tmp = load('debug_rb_nonlin_evol_simulation');
27 
28  % plot computed ll_E values on subgrid
29 
30  UN_local_ext = -ones(size(tmp.U_local_ext));
31 
32  UN_local_ext(tmp.reduced_data.TM_local) = tmp.U_local;
33 
34  % plot data before operator evaluation
35  figure, plot_element_data(tmp.reduced_data.grid_local_ext,...
36  tmp.U_local_ext, ...
37  tmp.params);
38  title('U_local_ext before operator evaluation');
39  % plot data after operator evaluation
40  figure, plot_element_data(tmp.reduced_data.grid_local_ext,...
41  UN_local_ext,tmp.params);
42  ax = gca;
43  title('UN_local_ext after operator evaluation');
44 
45  % plot exact reconstruction before Galerkin projection
46  sigma = detailed_data.BM(1:params.M,1:params.M) \ tmp.ll_E;
47  UNreconstr = detailed_data.QM(:,1:params.M) * sigma;
48  figure, plot_element_data(detailed_data.grid,...
49  UNreconstr,tmp.params);
50  title('Exact EI-reconstruction');
51 % set(ax,'clim',get(gca,'clim'));
52 
53 % check difference in points: real interpolated values obtained?
54 
55 mask = zeros(1,detailed_data.grid.nelements);
56 nbi = detailed_data.grid.NBI(detailed_data.TM,:);
57 i = find(nbi>0);
58 mask(nbi(i)) = 1;
59 mask(detailed_data.TM) = 2;
60 local_ext_ind = find(mask);
61 UNreconstr_local_ext = UNreconstr(local_ext_ind);
62 UNreconstr_local = UNreconstr_local_ext(tmp.reduced_data.TM_local(1:params.M));
63 
64 figure,plot([UNreconstr_local(:), tmp.ll_E(:)]);
65 legend({'ei-reconstruction-values','local_eval'});
66 title(['Comparison of local evaluation values and the values',...
67  ' of the resulting interpolant']);
68 
69 % peform galerkin projection and reconstruction, plot result
70 A = feval(params.inner_product_matrix_algorithm,detailed_data.grid,params);
71 a = detailed_data.RB' * A * UNreconstr;
72 UN_RBreconstr = detailed_data.RB * a;
73 figure, plot_element_data(detailed_data.grid,...
74  UN_RBreconstr,tmp.params);
75 title('RB-reconstruction of EI-projection');
76 
77 figure,plot([tmp.rhs, -params.dt * a(:)]);
78 legend({'reconstr','simulation'});
79 title(['Comparison of RB-coefficients from explicit reconstruction ', ...
80  'and simulation.']);
81 
82 
83 
84 
85 
86 % TO BE ADJUSTED TO NEW SYNTAX
87 %| \docupdate