rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
quadr_nonlin_script.m
1 function quadr_nonlin_script(step)
2 %function quadr_nonlin_script(step)
3 %
4 % step 1: detailed simulation and plot
5 % step 10: demo_rb_gui
6 %
7 % B. Haasdonk 8.12.2011
8 
9 if nargin == 0
10  step = 1;
11 end;
12 
13 switch step
14  case 1
16  model_data = gen_model_data(model);
17  model = set_mu(model,[0.1,1]);
18  sim_data = detailed_simulation(model, model_data);
19  p = plot_sim_data(model, model_data, sim_data,[]);
20 
21  case 2 % demo_rb_gui of detailed_simulation
22  % setting rb-pointers to dummy-functions, such that
23  % rb simulation does simply do a full simulation:
24  model = quadratic_poisson_model;
25  model.gen_detailed_data = @(model,model_data) model_data;
26  model.gen_reduced_data = @(model,detailed_data) detailed_data;
27  model.rb_simulation = model.detailed_simulation;
28  model.rb_reconstruction = ...
29  @(model,detailed_data,rb_sim_data) ...
30  rb_sim_data;
31  % end of setting pointers.
32  model_data = gen_model_data(model);
33  detailed_data = gen_detailed_data(model, model_data);
34  demo_rb_gui(model, detailed_data);
35 
36  case 3 % simple reduced basis generation and plot
38  model_data = gen_model_data(model);
39  detailed_data = gen_detailed_data(model, model_data);
40  plot(model_data.grid.X(2:end-1),detailed_data.RB)
41  title(['Reduced basis with ',...
42  num2str(size(detailed_data.RB,2)),...
43  ' basis vectors']);
44 
45  case 4 % reduced simulation and error for single parameter
46 
48  model_data = gen_model_data(model);
49  detailed_data = gen_detailed_data(model, model_data);
50  reduced_data = gen_reduced_data(model, detailed_data);
51  mu =[1,1];
52  model = set_mu(model,mu);
53  rb_sim_data = rb_simulation(model, reduced_data);
54  rb_sim_data = rb_reconstruction(model, detailed_data, rb_sim_data)
55  sim_data = detailed_simulation(model, model_data);
56  plot_params = [];
57  err = [];
58  err.u = sim_data.u - rb_sim_data.u;
59  plot_params.title = ['error u-uN for mu=',num2str(mu)];
60  plot_sim_data(model,detailed_data,err,plot_params);
61  figure;
62  plot_params.title = ['uN and u for mu=',num2str(mu)];
63  plot_params.legend ={'u','u_N'};
64  joint = [];
65  joint.u = [rb_sim_data.u, sim_data.u];
66  plot_sim_data(model,detailed_data,joint,plot_params);
67 
68  case 5 % rb_demo_gui
70  model_data = gen_model_data(model);
71  detailed_data = gen_detailed_data(model, model_data);
72  demo_rb_gui(model, detailed_data);
73 
74  otherwise
75  error('step unknown');
76 end;
77