1 function reduced_data = lin_stat_gen_reduced_data(model,detailed_data)
2 %
function reduced_data = lin_stat_gen_reduced_data(model,detailed_data)
4 %
function computing reduced data.
6 % B. Haasdonk 22.2.2011
10 old_mode = model.decomp_mode;
12 model.decomp_mode = 1; % == components
14 [A_comp,f_comp] = model.operators(model,detailed_data);
17 reduced_data.Q_A = Q_A;
19 reduced_data.Q_f = Q_f;
21 reduced_data.AN_comp = cell(1,length(A_comp));
23 reduced_data.AN_comp{q} = ...
24 detailed_data.RB
'*A_comp{q}*detailed_data.RB;
27 reduced_data.fN_comp = cell(1,length(f_comp));
29 reduced_data.fN_comp{q} = ...
30 detailed_data.RB' * f_comp{q};
33 if model.compute_output_functional
34 % assumption: nonparametic output functional, then simple RB
37 model.operators_output(model,detailed_data);
39 reduced_data.lN_comp = cell(1,Q_l);
41 reduced_data.lN_comp{q} = detailed_data.RB
' * l_comp{q};
45 N = model.get_rb_size(model,detailed_data);
48 % plus error estimation quantities
50 % G = (v_r^q, v_r^q) = v_r^q' * K * v_r^q
51 % with {v_r^q}_q = (v_f^q, v_a^qq
')_{qq'}
52 % G = [Gff, Gfa; Gfa', Gaa];
54 % (v_f^q,v_f^q
') = v_f^q' * K * v_f^q
56 % matrices of coefficient vectors of Riesz-representers:
57 % K * v_f^q = f^q (coefficient vector equations)
58 K = model.get_inner_product_matrix(detailed_data);
59 % search solution in H10, i.e.
set dirichlet DOFs
63 v_f = zeros(size(detailed_data.RB,1),Q_f);
64 K_v_f = zeros(size(detailed_data.RB,1),Q_f);
66 K_v_f(:,q) = f_comp{q};
67 v_f(:,q) = K \ f_comp{q};
73 K_v_a{n} = zeros(size(K,1),Q_A);
74 v_a{n} = zeros(size(K,1),Q_A);
76 K_v_a{n}(:,q) = (A_comp{q}*detailed_data.RB(:,n));
77 v_a{n}(:,q) = K \ K_v_a{n}(:,q);
81 % compute matrix G components = [G_ff, G_fa{n}; G_fa{n}', G_aa{n}];
82 reduced_data.Gff = v_f
' * K_v_f;
83 reduced_data.Gfa = cell(1,N);
85 reduced_data.Gfa{n} = v_f' * K_v_a{n};
87 reduced_data.Gaa = cell(N,N);
90 reduced_data.Gaa{n1,n2} = v_a{n1}
' * K_v_a{n2};
94 % finally assemble G = [G_ff, G_fa{n}; G_fa{n}', G_aa{n}];
97 G(1:Q_f,1:Q_f) = reduced_data.Gff;
99 G(1:Q_f,Q_f+(n-1)*Q_A +(1:Q_A)) = ...
101 G(Q_f+(n-1)*Q_A +(1:Q_A),1:Q_f) = ...
102 reduced_data.Gfa{n}
';
106 G(Q_f+(n1-1)*Q_A+(1:Q_A),Q_f+(n2-1)*Q_A +(1:Q_A)) = ...
107 reduced_data.Gaa{n1,n2};
112 if model.use_scm % when scm shall be used generate offline data here
113 if ~isfield(detailed_data, 'A_comp
')
114 detailed_data.A_comp = A_comp; % the components are required for the SCM to work
116 % Note by Dominik Garmatter 20.09 2012 regarding a problem with this
118 % It makes sense to compute the scm_offline_data in gen_reduced_data, but
119 % when generating a reduced basis there might be a call of gen_reduced_data
120 % in every step of the basis generation. This will result in multiple
121 % generations of scm_offline_data but scm_offline_data is not dependant on
122 % the reduced basis and therefore it would be sufficient to compute it only
123 % once. But there is no real solution to this problem yet, because one
124 % might need the SCM while basis generation (i.e. to compute the error
125 % indicators). Otherwise one could disable the SCM while basis generation
126 % (model.use_scm = 0) and enable it after basis generation.
127 reduced_data.scm_offline_data = scm_offline(model, detailed_data);
130 % set back old model mode
131 model.decomp_mode = old_mode;