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