rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
demo_vi.m
1 function demo_vi()
2 %function demo_vi()
3 %
4 % function testing the implementation of the RB-Method for
5 % Parametrizes Variational Inequalities
6 
7 % I.Maier 31.05.2011
8 
9 params.H = 201;
10 
11 model = elastic_rope_model(params);
12 disp('model created');
13 model_data = gen_model_data(model);
14 
15 fn = 'detailed_data_vi.mat';
16 
17 if 1
18  % detailed simulation and plot
19  disp('begin detailed simulation');
20  sim_data = detailed_simulation(model,model_data);
21  disp('plotting ...');
22  plot_params.plot_title = 'detailed solution & obstacle';
23  p = plot_sim_data(model,model_data,sim_data,plot_params);
24 
25  %g = model.obstacle(model_data.X,model);
26  %figure(p),
27  %hold on;
28  %plot(model_data.X,g,'c','Linewidth',4);
29  %title('detailed solution & obstacle');
30  %hold off;
31 
32  % rb generation
33  disp('compute snapshots');
34  detailed_data = gen_detailed_data(model,model_data);
35  %save('detailed_data_vi.mat','model','detailed_data');
36 
37  reduced_data = gen_reduced_data(model,detailed_data);
38 
39  % rb simulation and plot
40  disp('begin reduced simulation');
41  rb_sim_data = rb_simulation(model,reduced_data);
42  rb_sim_data = rb_reconstruction(model,detailed_data,rb_sim_data);
43  disp('plotting ...');
44  plot_params.plot_title = 'reduced solution & obstacle';
45  p = plot_sim_data(model,model_data,rb_sim_data,plot_params);
46 
47  % error computation
48  disp('compute errors and norms');
49  K = model.get_inner_product_matrix(model,model_data);
50  U_err = sqrt((rb_sim_data.U-sim_data.U)' * K * (rb_sim_data.U- ...
51  sim_data.U));
52  L_R = K \ (rb_sim_data.L-sim_data.L);
53  L_err = sqrt((rb_sim_data.L-sim_data.L)' * L_R);
54  disp(['error (U-UN): ',num2str(U_err)]);
55  disp(['error (L-LN): ',num2str(L_err)]);
56 
57  U_norm = sqrt(sim_data.U' * K * sim_data.U);
58  L_R = K \ sim_data.L;
59  L_norm = sqrt(sim_data.L' * L_R);
60  disp(['norm U: ',num2str(U_norm)]);
61  disp(['norm L: ',num2str(L_norm)]);
62  if ~exist(fn);
63  save(fn,'model','detailed_data');
64  end;
65 
66 end % if 0
67 
69 if 1
70  load(fn);
71  model.mu_fix = 30/200;
72  plot_params = [];
73  plot_params.no_lines = 0;
74  plot_params.axis_tight = 1;
75  demo_rb_gui(model,detailed_data,[],plot_params);
76 end