3 %
function reduced_data = dom_dec_reduced_data(model,detailed_data)
4 % all required offline data
for the rb-simulation is computed.
5 % there are two ingredients
for the error estimator - the jump
6 % across `\Gamma` and the residuum.
8 % the computation of residuum-components needs
9 % Q_f+N1*Q_A1+N2*Q_A2 detailed simulations. the number of
10 % iterations is very high there, because the accuracy of the error
11 % estimator is good then. therefore very expensive computations.
13 % Generated fields of reduced_data:
14 % AN_comp: nested cell containing the components of the system matrizes
16 % fN_comp: nested cell containing the components of the right hand
17 % side vectors
for the subproblems
18 % R_11, R_12, R_22: matrizes
for the computation of the jump
19 % across `\Gamma` component of the error estimator
20 % G: cell containing the matrizes
for the residuum component
21 % N: cell with the dimensions of the RB spaces
22 % I_0, I_G: cells with index vectors of `0` and `\Gamma` spaces
26 dir = model.dirichlet_side;
27 no_dir = mod(dir,2)+1;
31 model.decomp_mode = 1;
33 % A_comp and f_comp are nested cells!
34 [A_comp, f_comp, ~, ~] = ...
35 model.operators(model,detailed_data);
37 % number of matrix/vector components
42 Q_A{i} = length(A_comp{i});
43 Q_f{i} = length(f_comp{i});
45 N{i} = size(detailed_data.RB{i},2);
49 reduced_data.I_0 = detailed_data.I_0;
50 reduced_data.I_G = detailed_data.I_G;
52 reduced_data.AN_comp = cell(1,2);
53 reduced_data.fN_comp = cell(1,2);
56 reduced_data.AN_comp{i} = cell(1,Q_A{i});
58 reduced_data.AN_comp{i}{q} = detailed_data.RB{i}
' * ...
59 A_comp{i}{q} * detailed_data.RB{i};
62 reduced_data.fN_comp{i} = cell(1,Q_f{i});
64 reduced_data.fN_comp{i}{q} = detailed_data.RB{i}' * ...
69 %%%%%%%%%%% computation of extension matrizes
70 K = model.get_inner_product_matrices(detailed_data);
72 if model.base_model.dual_mode
79 % trivial finite element extension
81 RB_ext{i} = zeros(size(detailed_data.RB{ext_ind},1), ...
82 size(detailed_data.RB{i},2));
83 RB_ext{i}(detailed_data.gamma_dofs{ext_ind},:) = ...
84 detailed_data.RB{i}(detailed_data.gamma_dofs{i},:);
86 reduced_data.R_11 = RB_ext{dir}
' * K{ext_ind} * RB_ext{dir};
87 reduced_data.R_12 = RB_ext{dir}' * K{ext_ind} * RB_ext{no_dir};
88 reduced_data.R_22 = RB_ext{no_dir}
' * K{ext_ind} * RB_ext{no_dir};
90 % output functional terms
91 if model.base_model.compute_output_functional && ~model.base_model.dual_mode
93 model.base_model.dual_mode = 1;
94 reduced_data.dual_reduced_data = ...
95 gen_reduced_data(model,detailed_data.dual_detailed_data);
96 model.base_model.dual_mode = 0;
98 RBext_dual = cell(1,2);
101 zeros(size(detailed_data.RB{no_dir},1), ...
102 size(detailed_data.dual_detailed_data.RB{i},2));
103 RBext_dual{i}(detailed_data.gamma_dofs{no_dir},:) = ...
104 detailed_data.dual_detailed_data.RB{i}(detailed_data.gamma_dofs{i},:);
109 model.base_model.decomp_mode = model.decomp_mode;
111 detailed_data.df_info = detailed_data.df_infos{i};
112 v_comp{i} = model.operators_output(model.base_model,detailed_data);
117 Q_v{i} = length(v_comp{i});
120 reduced_data.vN_comp = cell(1,2);
122 reduced_data.vN_comp{i} = cell(1, Q_v{i});
124 reduced_data.vN_comp{i}{q} = detailed_data.RB{i}' * v_comp{i}{q};
128 reduced_data.vNext_comp = cell(1, 2);
130 reduced_data.vNext_comp{i} = cell(1, Q_v{dir});
132 reduced_data.vNext_comp{i}{q} = RB_ext{i}
' * v_comp{dir}{q};
136 reduced_data.vNfR_comp = cell(1, 2);
138 reduced_data.vNfR_comp{i} = cell(1, Q_f{dir});
140 reduced_data.vNfR_comp{i}{q} = RBext_dual{i}' * f_comp{no_dir}{q};
144 reduced_data.fN_d_comp = cell(1, 2);
146 reduced_data.fN_d_comp{i} = cell(1,Q_f{i});
148 reduced_data.fN_d_comp{i}{q} = ...
149 detailed_data.dual_detailed_data.RB{i}
' * f_comp{i}{q};
153 reduced_data.AN_pd_comp = cell(1, 2);
155 reduced_data.AN_pd_comp{i} = cell(1,Q_A{i});
157 reduced_data.AN_pd_comp{i}{q} = ...
158 detailed_data.dual_detailed_data.RB{i}' * ...
159 A_comp{i}{q} * detailed_data.RB{i};
163 reduced_data.vNAR1_comp = cell(1, 2);
165 reduced_data.vNAR1_comp{i} = cell(1, Q_A{no_dir});
166 for q = 1:Q_A{no_dir}
167 reduced_data.vNAR1_comp{i}{q} = RBext_dual{i}
' * A_comp{no_dir}{q} * ...
168 detailed_data.RB{no_dir};
172 reduced_data.vNAR2_comp = cell(1, 2);
174 reduced_data.vNAR2_comp{i} = cell(1, Q_A{dir});
176 reduced_data.vNAR2_comp{i}{q} = ...
177 detailed_data.dual_detailed_data.RB{dir}' * A_comp{dir}{q} * ...
184 % error estimation quantities
185 model.base_model.compute_output_functional = 0;
187 %%%%%%%%%%%%% computation of residuum-components
188 % perform a detailed simulation
for each component
196 dir_gids = detailed_data.df_infos{i}.dirichlet_gids;
197 mat_dir = sparse(dir_gids,dir_gids,ones(size(dir_gids)), ...
198 detailed_data.df_infos{i}.ndofs, ...
199 detailed_data.df_infos{i}.ndofs);
200 res_mat{i}(dir_gids,:) = 0;
201 res_mat{i} = res_mat{i} + mat_dir;
205 % assume Q_f{1}=Q_f{2}
206 % v_f has one part on each domain
209 v_f{i} = zeros(size(res_mat{i},1),Q_f{i});
213 if any(f_comp{1}{q}) || any(f_comp{2}{q})
215 % prepare detailed simulation
216 detailed_data.operators = @(j) deal(res_mat{j}, f_comp{j}{q});
218 % detailed simulation
219 sim_data = detailed_simulation(model,detailed_data);
220 if sim_data.reached_maxiter
221 warning(
'detailed simulation may have diverged!');
224 v_f{i}(:,q) = sim_data.uh{i}.dofs;
230 % two different right hand sides
for v_a
231 % (v_a{1}{m},phi) = a_1(phi_N^m,phi)
232 % (v_a{2}{m},phi) = a_2(phi_N^m,phi)
236 v_a{i} = cell(1,N{i});
239 % v_a{i}{m} has one part on each domain
240 v_a{i}{m} = cell(1,2);
242 v_a{i}{m}{j} = zeros(size(res_mat{j},1),Q_A{i});
246 if any(any(A_comp{i}{q}))
248 % prepare detailed simulation
249 res_rhs{i} = A_comp{i}{q} * detailed_data.RB{i}(:,m);
250 res_rhs{mod(i,2)+1} = zeros(size(res_mat{mod(i,2)+1},1),1);
251 detailed_data.operators = @(j) deal(res_mat{j}, ...
254 % detailed simulation
255 sim_data = detailed_simulation(model,detailed_data);
256 if sim_data.reached_maxiter
257 warning(
'detailed simulation may have diverged!');
260 v_a{i}{m}{j}(:,q) = sim_data.uh{j}.dofs;
269 reduced_data.G = cell(1,2);
271 % two matrizes G (same procedure as in lin_stat_gen_reduced_data)
274 Gff = v_f{i}
' * K{i} * v_f{i};
278 Gfa1{n} = v_f{i}' * K{i} * v_a{1}{n}{i};
282 Gfa2{n} = v_f{i}
' * K{i} * v_a{2}{n}{i};
285 Ga1a1 = cell(N{1},N{1});
288 Ga1a1{n1,n2} = v_a{1}{n1}{i}' * K{i} * v_a{1}{n2}{i};
291 Ga1a2 = cell(N{1},N{2});
294 Ga1a2{n1,n2} = v_a{1}{n1}{i}
' * K{i} * v_a{2}{n2}{i};
297 Ga2a2 = cell(N{2},N{2});
300 Ga2a2{n1,n2} = v_a{2}{n1}{i}' * K{i} * v_a{2}{n2}{i};
304 Q_r = Q_f{1}+N{1}*Q_A{1}+N{2}*Q_A{2};
306 G(1:Q_f{1},1:Q_f{1}) = Gff;
308 G(1:Q_f{1},Q_f{1}+(n-1)*Q_A{1}+(1:Q_A{1})) = Gfa1{n};
309 G(Q_f{1}+(n-1)*Q_A{1}+(1:Q_A{1}),1:Q_f{1}) = Gfa1{n}
';
312 G(1:Q_f{1},Q_f{1}+N{1}*Q_A{1}+(n-1)*Q_A{2}+(1:Q_A{2})) = ...
314 G(Q_f{1}+N{1}*Q_A{1}+(n-1)*Q_A{2}+(1:Q_A{2}),1:Q_f{1}) = ...
319 G(Q_f{1}+(n1-1)*Q_A{1}+(1:Q_A{1}),Q_f{1}+(n2-1)*Q_A{1}+(1:Q_A{1})) ...
326 G(Q_f{1}+(n1-1)*Q_A{1}+(1:Q_A{1}),Q_f{1}+N{1}*Q_A{1}+ ...
327 (n2-1)*Q_A{2}+(1:Q_A{2})) = Ga1a2{n1,n2};
328 G(Q_f{1}+N{1}*Q_A{1}+(n2-1)*Q_A{2}+(1:Q_A{2}),Q_f{1}+ ...
329 (n1-1)*Q_A{1}+(1:Q_A{1})) = Ga1a2{n1,n2}
';
335 G(Q_f{1}+N{1}*Q_A{1}+(n1-1)*Q_A{2}+(1:Q_A{2}),Q_f{1}+ ...
336 N{1}*Q_A{1}+(n2-1)*Q_A{2}+(1:Q_A{2})) = Ga2a2{n1,n2};
340 reduced_data.G{i} = G;
344 if exist('v_comp
', 'var
')
345 model.base_model.compute_output_functional = 1;
function reduced_data = dom_dec_gen_reduced_data(model, detailed_data)
all required offline data for the rb-simulation is computed. there are two ingredients for the error ...