1 function reduced_data = comsol_evol_gen_reduced_data(model,detailed_data)
2 %
function reduced_data = comsol_evol_gen_reduced_data(model,detailed_data)
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!
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
14 % After the necessary preparations are done,
this function calls the
15 % rbmatlab
function lin_evol_gen_reduced_data to calculate the reduced
22 if size(detailed_data.RB,1) ~= size(detailed_data.ind_vectors.com_DOF_ind,1) %full vectors? --> eliminate DBC_data!
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;
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');
41 % generate reduced data using the corresponding rbmatlab function:
42 reduced_data = lin_evol_gen_reduced_data(model,detailed_data);
44 % if model.compute_output_functional
45 % model.name_output_functional = 'comsol_defined_output'; %needed, that the rb_simulation also calculates the output!
47 % if exist('name_output_functional','var')
48 % model.name_output_functional = name_output_functional;
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;
59 reduced_data.ind_vectors = detailed_data.ind_vectors;