1 function reduced_data = dom_dec_gen_reduced_data(model, ...
3 %
function reduced_data = dom_dec_reduced_data(model,detailed_data)
5 % all required offline data
for the rb-simulation is computed.
6 % there are two ingredients for the error estimator - the jump
7 % across `\Gamma` and the residuum.
9 % the computation of residuum-components needs
10 % Q_f+N1*Q_A1+N2*Q_A2 detailed simulations. the number of
11 % iterations is very high there, because the accuracy of the error
12 % estimator is good then. therefore very expensive computations.
14 % Generated fields of reduced_data:
15 % AN_comp: nested cell containing the components of the system matrizes
17 % fN_comp: nested cell containing the components of the right hand
18 % side vectors for the subproblems
19 % R_11, R_12, R_22: matrizes for the computation of the jump
20 % across `\Gamma` component of the error estimator
21 % G: cell containing the matrizes for the residuum component
22 % N: cell with the dimensions of the RB spaces
23 % I_0, I_G: cells with index vectors of `0` and `\Gamma` spaces
27 dir = model.dirichlet_side;
28 no_dir = mod(dir,2)+1;
32 model.decomp_mode = 1;
34 % A_comp and f_comp are nested cells!
35 [A_comp, f_comp, dummy1, dummy2] = ...
36 model.operators(model,detailed_data);
38 % number of matrix/vector components
43 Q_A{i} = length(A_comp{i});
44 Q_f{i} = length(f_comp{i});
46 N{i} = size(detailed_data.RB{i},2);
50 reduced_data.I_0 = detailed_data.I_0;
51 reduced_data.I_G = detailed_data.I_G;
53 reduced_data.AN_comp = cell(1,2);
54 reduced_data.fN_comp = cell(1,2);
57 reduced_data.AN_comp{i} = cell(1,Q_A{i});
59 reduced_data.AN_comp{i}{q} = detailed_data.RB{i}
' * ...
60 A_comp{i}{q} * detailed_data.RB{i};
63 reduced_data.fN_comp{i} = cell(1,Q_f{i});
65 reduced_data.fN_comp{i}{q} = detailed_data.RB{i}' * ...
70 % error estimation quantities
71 K = model.get_inner_product_matrices(detailed_data);
73 %%%%%%%%%%% computation of extension matrizes
76 % trivial finite element extension
78 RB_ext{i} = zeros(size(detailed_data.RB{dir},1), ...
79 size(detailed_data.RB{i},2));
80 RB_ext{i}(detailed_data.gamma_dofs{dir},:) = ...
81 detailed_data.RB{i}(detailed_data.gamma_dofs{i},:);
83 reduced_data.R_11 = RB_ext{dir}
' * K{dir} * RB_ext{dir};
84 reduced_data.R_12 = RB_ext{dir}' * K{dir} * RB_ext{no_dir};
85 reduced_data.R_22 = RB_ext{no_dir}
' * K{dir} * RB_ext{no_dir};
87 %%%%%%%%%%%%% computation of residuum-components
88 % perform a detailed simulation for each component
96 dir_gids = detailed_data.df_infos{i}.dirichlet_gids;
97 mat_dir = sparse(dir_gids,dir_gids,ones(size(dir_gids)), ...
98 detailed_data.df_infos{i}.ndofs, ...
99 detailed_data.df_infos{i}.ndofs);
100 res_mat{i}(dir_gids,:) = 0;
101 res_mat{i} = res_mat{i} + mat_dir;
105 % assume Q_f{1}=Q_f{2}
106 % v_f has one part on each domain
109 v_f{i} = zeros(size(res_mat{i},1),Q_f{i});
113 if any(f_comp{1}{q}) || any(f_comp{2}{q})
115 % prepare detailed simulation
116 detailed_data.operators = @(j) deal(res_mat{j}, f_comp{j}{q});
118 % detailed simulation
119 sim_data = detailed_simulation(model,detailed_data);
120 if sim_data.reached_maxiter
121 warning('detailed simulation may have diverged!
');
124 v_f{i}(:,q) = sim_data.uh{i}.dofs;
130 % two different right hand sides for v_a
131 % (v_a{1}{m},phi) = a_1(phi_N^m,phi)
132 % (v_a{2}{m},phi) = a_2(phi_N^m,phi)
136 v_a{i} = cell(1,N{i});
139 % v_a{i}{m} has one part on each domain
140 v_a{i}{m} = cell(1,2);
142 v_a{i}{m}{j} = zeros(size(res_mat{j},1),Q_A{i});
146 if any(any(A_comp{i}{q}))
148 % prepare detailed simulation
149 res_rhs{i} = A_comp{i}{q} * detailed_data.RB{i}(:,m);
150 res_rhs{mod(i,2)+1} = zeros(size(res_mat{mod(i,2)+1},1),1);
151 detailed_data.operators = @(j) deal(res_mat{j}, ...
154 % detailed simulation
155 sim_data = detailed_simulation(model,detailed_data);
156 if sim_data.reached_maxiter
157 warning('detailed simulation may have diverged!
');
160 v_a{i}{m}{j}(:,q) = sim_data.uh{j}.dofs;
169 reduced_data.G = cell(1,2);
171 % two matrizes G (same procedure as in lin_stat_gen_reduced_data)
174 Gff = v_f{i}' * K{i} * v_f{i};
178 Gfa1{n} = v_f{i}
' * K{i} * v_a{1}{n}{i};
182 Gfa2{n} = v_f{i}' * K{i} * v_a{2}{n}{i};
185 Ga1a1 = cell(N{1},N{1});
188 Ga1a1{n1,n2} = v_a{1}{n1}{i}
' * K{i} * v_a{1}{n2}{i};
191 Ga1a2 = cell(N{1},N{2});
194 Ga1a2{n1,n2} = v_a{1}{n1}{i}' * K{i} * v_a{2}{n2}{i};
197 Ga2a2 = cell(N{2},N{2});
200 Ga2a2{n1,n2} = v_a{2}{n1}{i}
' * K{i} * v_a{2}{n2}{i};
204 Q_r = Q_f{1}+N{1}*Q_A{1}+N{2}*Q_A{2};
206 G(1:Q_f{1},1:Q_f{1}) = Gff;
208 G(1:Q_f{1},Q_f{1}+(n-1)*Q_A{1}+(1:Q_A{1})) = Gfa1{n};
209 G(Q_f{1}+(n-1)*Q_A{1}+(1:Q_A{1}),1:Q_f{1}) = Gfa1{n}';
212 G(1:Q_f{1},Q_f{1}+N{1}*Q_A{1}+(n-1)*Q_A{2}+(1:Q_A{2})) = ...
214 G(Q_f{1}+N{1}*Q_A{1}+(n-1)*Q_A{2}+(1:Q_A{2}),1:Q_f{1}) = ...
219 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})) ...
226 G(Q_f{1}+(n1-1)*Q_A{1}+(1:Q_A{1}),Q_f{1}+N{1}*Q_A{1}+ ...
227 (n2-1)*Q_A{2}+(1:Q_A{2})) = Ga1a2{n1,n2};
228 G(Q_f{1}+N{1}*Q_A{1}+(n2-1)*Q_A{2}+(1:Q_A{2}),Q_f{1}+ ...
229 (n1-1)*Q_A{1}+(1:Q_A{1})) = Ga1a2{n1,n2}';
235 G(Q_f{1}+N{1}*Q_A{1}+(n1-1)*Q_A{2}+(1:Q_A{2}),Q_f{1}+ ...
236 N{1}*Q_A{1}+(n2-1)*Q_A{2}+(1:Q_A{2})) = Ga2a2{n1,n2};
240 reduced_data.G{i} = G;