rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
comsol_evol_gen_reduced_data.m
1 function reduced_data = comsol_evol_gen_reduced_data(model,detailed_data)
2 %function reduced_data = comsol_evol_gen_reduced_data(model,detailed_data)
3 %
4 % This function generates the reduced_data from the detailed_data for
5 % COMSOL models for evolution problems. Before creating the reduced data,
6 % some matrices have to be cut from the full size to the eliminated
7 % version so that for example error estimators work correctly and no
8 % singular matrices are used!
9 %
10 % The creation of the output values reduced_data.s_RB is done here since it
11 % is better to calculate these values with the full solution instead of the
12 % eliminated one!
13 %
14 % After the necessary preparations are done, this function calls the
15 % rbmatlab function lin_evol_gen_reduced_data to calculate the reduced
16 % data!
17 %
18 % Oliver Zeeb, 2012
19 
20 
21 
22 if size(detailed_data.RB,1) ~= size(detailed_data.ind_vectors.com_DOF_ind,1) %full vectors? --> eliminate DBC_data!
23  RB=detailed_data.RB;
24  detailed_data.RB=detailed_data.RB(detailed_data.ind_vectors.com_DOF_ind,:);% DBC eliminated from reduced Basis!
25  detailed_data.W = detailed_data.W(detailed_data.ind_vectors.com_DOF_ind,detailed_data.ind_vectors.com_DOF_ind);
26  in_prod_mat_string = char(model.get_inner_product_matrix);
27  eval(['model.get_inner_product_matrix =',in_prod_mat_string,'_eliminated;']);
28  model.comsol_get_eliminated_data=1;
29 end
30 
31 %look if there is a field model.name_output_functional because that field
32 %is checked in lin_evol_gen_reduced_data for preparation of output-calculation!
33 %Since the output-preparation is not well/flexible implemented, I skip this
34 %part of lin_evol_gen_reduced_data by eliminating this field and after
35 %lin_evol_gen_reduced_data has run, I add the needed fields directly.
36 if isfield(model,'name_output_functional')
37  name_output_functional = model.name_output_functional;
38  model= rmfield(model, 'name_output_functional');
39 end
40 
41 % generate reduced data using the corresponding rbmatlab function:
42 reduced_data = lin_evol_gen_reduced_data(model,detailed_data);
43 
44 % if model.compute_output_functional
45 % model.name_output_functional = 'comsol_defined_output'; %needed, that the rb_simulation also calculates the output!
46 % end
47 % if exist('name_output_functional','var')
48 % model.name_output_functional = name_output_functional;
49 % end
50 
51 
52 if model.compute_output_functional
53  model.comsol_get_eliminated_data = 0;
54  [v, s_l2norm] = model.operators_output(model,detailed_data);
55  reduced_data.s_RB = (v' * RB)';
56  reduced_data.s_l2norm = s_l2norm;
57 end
58 
59 reduced_data.ind_vectors = detailed_data.ind_vectors;
60