rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
elastic_membrane.m
1 function res = elastic_membrane(step,params)
2 %function res = elastic_membrane(params)
3 %
4 % function elastic membrane
5 
6 % B. Haasdonk 12.3.2012
7 
8 res = [];
9 
10 if nargin<1
11  step = 4; % demo_rb_gui
12 end;
13 
14 model = elastic_membrane_model;
15 model_data = gen_model_data(model);
16 
17 switch step
18 
19  case 1 % detailed simulation with unconstrained fem solver
20 
21  % model = set_mu(model,[1,20]);
22  model = set_mu(model,[1,1]);
23  % model = set_mu(model,[1,0]);
24  model = set_mu(model,[20,0]);
25  model = set_mu(model,[20,1]);
26  model = set_mu(model,[0.3,0]);
27  model.operators = @fem_operators;
28  model.detailed_simulation = @lin_stat_detailed_simulation;
29  model.compute_output_functional = 0;
30  sim_data = filecache_function(@detailed_simulation,model,model_data);
31  sim_data.U = sim_data.uh.dofs(:);
32  sim_data.L = zeros(size(sim_data.U,1),1);
33  plot_sim_data(model,model_data,sim_data,[]);
34  view(-17,34);
35 
36  case 2 % detailed simulation with constrained fem solver
37 
38  model = set_mu(model,[20,1]);
39  model.dummy = 2;
40 % model = set_mu(model,[0.3,0]);
41  sim_data = filecache_function(@detailed_simulation,model,model_data);
42  plot_sim_data(model,model_data,sim_data,[]);
43  view(-17,34);
44 
45  case 3 % generate greedy reduced basis
46 
47  % rb-estimator with W subbasis for dual reduced basis:
48  model.RB_generation_mode = 'greedy-rb-estimator';
49  model.supremizer_enrichment = 1; % on/off
50  model.enable_error_estimator = 1;
51  model.RB_stop_Nmax = 20; % should suffice here!
52  model.RB_numintervals = [16,16];
53  model.dual_lin_independence_mode = 1; % use W subbasis
54 
55  disp('--------------------------------------------------');
56  disp(model.RB_generation_mode);
57  detailed_data = filecache_function(@gen_detailed_data,model,model_data);
58  save('elastic_membrane_detailed_data',...
59  'model','detailed_data');
60  max_err_sequence7 = detailed_data.RB_info.max_err_sequence;
61  plot(max_err_sequence7);
62  set(gca,'Yscale','log');
63  title('greedy rb-estimator, with supr.-enrichment, lin-indep=1');
64  disp('press enter to continue');
65  plot_detailed_data(model,detailed_data,[]);
66  keyboard;
67 
68  case 4 % demo_rb_gui
69  load('elastic_membrane_detailed_data') % from step 3
70  model.enable_error_estimator = 0;
71  plot_params = [];
72  plot_params.plot_title = 'elastic membrane';
73  plot_params.no_lines = 0;
74  demo_rb_gui(model,detailed_data,[],plot_params);
75 
76 % demo_detailed_gui(model,model_data);
77  view(-17,34);
78 
79  case 5 % generate animation of demo_rb_gui
80 
81  load('elastic_membrane_detailed_data') % from step 3
82  model.enable_error_estimator = 0;
83  plot_params = [];
84  plot_params.plot_title = 'elastic membrane';
85  plot_params.no_lines = 0;
86 % demo_rb_gui(model,detailed_data,[],plot_params);
87 
88  % demo_detailed_gui(model,model_data);
89  % loop_demo_rb_gui(gcf,'mu_1',0.1);
90 
91  % the problem is, that powerpoint cannot properly play these clips
92  % within a slide. So No compression is used to generate the avi.
93  % Then, for powerpoint-includion, use Programme/avi2mpeg to generate a
94  % mpeg movie
95 
96  % Bernard Haasdonk 25.5.2008
97 
98  text_sequence = {''};
99 
100  outputfn = 'rb_elastic_membrane3.avi';
101  mu_sequence = [0.3*ones(1,41); 0:0.025:1];
102 
103  reduced_data = gen_reduced_data(model,detailed_data);
104  quality = 75;
105  compression = 'None';
106  %compression = 'Cinepak';
107  %compression = 'Indeo5';
108  %compression = 'IV50';
109  %compression = 'Indeo5'; % Indeo3, Cinepak, MSVC, RLE, None
110  %compression='TSCC';
111  fps = 15;
112  mov = avifile(outputfn,'Fps',fps,'Quality',quality,...
113  'Compression',compression);
114  plot_params.show_colorbar = 1;
115 
116  for i = 1:length(mu_sequence)
117 
118  model = set_mu(model,mu_sequence(:,i));
119  sim_data = rb_simulation(model,reduced_data);
120  sim_data = rb_reconstruction(model,detailed_data,sim_data);
121 
122  cla;
123  plot_sim_data(model,model_data,sim_data,plot_params);
124  view(-17,34);
125  % text(0.1,0.9,text_sequence{i},'FontSize',30,'Color',[0,0,1])
126  F = getframe(gcf);
127  %F = getframe(gca);
128  pause(0.01);
129  mov = addframe(mov,F);
130  % -15,-78
131  end;
132  mov = close(mov);
133 
134  otherwise
135  disp('step unknown')
136 end;
function varargout = filecache_function(funcptr, varargin)
function used for file-caching other function calls.
function demo_rb_gui(varargin)
reduced basis demo with sliders
Definition: demo_rb_gui.m:17
function demo_detailed_gui(varargin)
demo gui for detailed simulations (calling demo_rb_gui after switching some pointers) ...
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