rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
step5_rb_generation.m
Go to the documentation of this file.
1 % script constructing a reduced basis space
2 %
3 % required variables that need to be set:
4 % - 'CRBfname'
5 % - 'plot_params'
6 %
7 % optional variables that can be set:
8 % - 'detailedfname': filename of MAT-file where the computed
9 % 'detailed_data' structure is stored. If this
10 % variable is empty, it is set to
11 % '[model.name, infix, '_detailed_interpol.mat'],
12 % where 'infix' is set to either 'model.model_type'
13 % if existent or the empty string.
14 %
15 % generated variables:
16 % - 'detailed_data': structure containing the reduced basis space and
17 % information on its construction process.
18 %
19 
20 disp('constructing reduced bases')
21 %tmp = load(fullfile(rbmatlabresult,CRBfname));
22 %detailed_data = tmp.detailed_data;
23 
24 %if structcmp(model, tmp.model) ~= 1
25 % warning('model has changed since crb basis generation.');
26 %end
27 
28 
29 detailed_data.W = model_data.W;
30 if ~isfield(params,'Mstrich')
31  params.Mstrich = 0;
32 end
33 if params.Mstrich == 0
34  model.enable_error_estimator = 0;
35 end
36 
37 
38 if ~isfield(params,'M')
39  model.M = cellfun(@(x)(size(x,2) - model.Mstrich), detailed_data.BM, 'UniformOutput', true) ...
40  - params.Mstrich;
41 else
42  model.M = params.M;
43 end
44 model.Mstrich = params.Mstrich;
45 
46 tic;
47 detailed_data = rb_basis_generation(model, detailed_data);
48 t = toc;
49 
50 detailed_data.RB_info.elapsed_time = t;
51 if isempty(detailedfname)
52  if isfield(model, 'model_type')
53  infix = model.model_type;
54  else
55  infix = '';
56  end
57  detailedfname = [model.name, infix, '_detailed.mat'];
58 end
59 save(fullfile(rbmatlabresult,detailedfname),...
60  'detailed_data','model','plot_params');
61 
62 plot(detailed_data.RB_info.max_err_sequence);
63 set(gca,'Yscale','log');
64 title('RB-generation error convergence');
65