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 %Q_A = length(detailed_data.A_comp);
11 Q_A = size(detailed_data.A_comp,2);
12 reduced_data.Q_A = Q_A;
13 %Q_f = length(detailed_data.f_comp);
14 Q_f = size(detailed_data.f_comp,2);
15 H = size(detailed_data.f_comp,1); % number of DOFs
16 reduced_data.Q_f = Q_f;
17 N = model.get_rb_size(model,detailed_data);
20 %
for error estimation:
23 K_v_r(:,1:Q_f) = detailed_data.f_comp;
25 % store reduced system matrix components as column vector
26 reduced_data.AN_comp = zeros(N^2,Q_A);
27 %Aq_times_RB = zeros(H,Q_A);
29 % reconstruct sparse system matrix from coeffs+sparsity-pattern:
30 Aq_vec = detailed_data.A_comp(:,q);
31 i = detailed_data.A_row_indices;
32 j = detailed_data.A_column_indices;
33 siz = detailed_data.A_size;
34 Aq = sparse(i,j,Aq_vec, siz(1), siz(2));
35 AqRB = Aq*detailed_data.RB;
36 AN_comp_q = detailed_data.RB
'*AqRB;
37 reduced_data.AN_comp(:,q) = AN_comp_q(:);
38 col_ind = Q_f+(q-1)*N+1;
39 K_v_r(:,(col_ind):(col_ind+N-1)) = AqRB;
42 reduced_data.fN_comp = zeros(N,Q_f);
44 reduced_data.fN_comp(:,q) = ...
45 detailed_data.RB' * detailed_data.f_comp(:,q);
48 if model.compute_output_functional
50 % model.operators_output(model,detailed_data);
51 Q_l = length(detailed_data.l_comp);
52 reduced_data.lN_comp = detailed_data.RB
' * detailed_data.l_comp;
55 K = model.get_inner_product_matrix(detailed_data);
59 %%% If we implement improvement of Stephan Rave:
60 %v =
VecMat.gram_schmidt_reiterate(v_r, K, 1e-12);
62 %%% then also in rb_simulation a change must be applied:
63 % %without orthonormalization:
67 % plus error estimation quantities
68 % G = (v_r^q, v_r^q) = v_r^q' * K * v_r^q
69 % with {v_r^q}_q = (v_f^q, v_a^q
'n)_{q'n}
70 % G = [Gff, Gfa; Gfa
', Gaa];
72 % (v_f^q,v_f^q') = v_f^q
' * K * v_f^q
73 % matrices of coefficient vectors of Riesz-representers:
74 % K * v_f^q = f^q (coefficient vector equations)
77 %v_f = zeros(size(detailed_data.RB,1),Q_f);
78 %K_v_f = zeros(size(detailed_data.RB,1),Q_f);
80 % K_v_f(:,q) = f_comp{q};
81 % v_f(:,q) = K \ f_comp{q};
86 % K_v_a{n} = zeros(size(K,1),Q_A);
87 % v_a{n} = zeros(size(K,1),Q_A);
89 % K_v_a{n}(:,q) = (A_comp{q}*detailed_data.RB(:,n));
90 % v_a{n}(:,q) = K \ K_v_a{n}(:,q);
93 % compute matrix G components = [G_ff, G_fa{n}; G_fa{n}', G_aa{n}];
94 %reduced_data.Gff = v_f
' * K_v_f;
95 %reduced_data.Gfa = cell(1,N);
97 % reduced_data.Gfa{n} = v_f' * K_v_a{n};
99 %reduced_data.Gaa = cell(N,N);
102 % reduced_data.Gaa{n1,n2} = v_a{n1}
' * K_v_a{n2};
105 % finally assemble G = [G_ff, G_fa{n}; G_fa{n}', G_aa{n}];
106 %Q_r = Q_f + N * Q_A;
108 %G(1:Q_f,1:Q_f) = reduced_data.Gff;
110 % G(1:Q_f,Q_f+(n-1)*Q_A +(1:Q_A)) = ...
111 % reduced_data.Gfa{n};
112 % G(Q_f+(n-1)*Q_A +(1:Q_A),1:Q_f) = ...
113 % reduced_data.Gfa{n}
';
117 % G(Q_f+(n1-1)*Q_A+(1:Q_A),Q_f+(n2-1)*Q_A +(1:Q_A)) = ...
118 % reduced_data.Gaa{n1,n2};
123 if model.use_scm % when scm shall be used generate offline data here
124 if ~isfield(detailed_data, 'A_comp
')
125 error('The components are required
for the SCM to work.
');
126 % detailed_data.A_comp = A_comp; % the components are required for the SCM to work
128 % Note by Dominik Garmatter 20.09 2012 regarding a problem with this
130 % It makes sense to compute the scm_offline_data in gen_reduced_data, but
131 % when generating a reduced basis there might be a call of gen_reduced_data
132 % in every step of the basis generation. This will result in multiple
133 % generations of scm_offline_data but scm_offline_data is not dependant on
134 % the reduced basis and therefore it would be sufficient to compute it only
135 % once. But there is no real solution to this problem yet, because one
136 % might need the SCM while basis generation (i.e. to compute the error
137 % indicators). Otherwise one could disable the SCM while basis generation
138 % (model.use_scm = 0) and enable it after basis generation.
139 reduced_data.scm_offline_data = scm_offline(model, detailed_data);