rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
lin_stat_rb_simulation.m
1 function rb_sim_data = lin_stat_rb_simulation(model,reduced_data)
2 %function rb_sim_data = lin_stat_rb_simulation(model,reduced_data)
3 %
4 % function performing a reduced simulation
5 
6 % B. Haasdonk 22.2.2011
7 
8 rb_sim_data =[];
9 
10 old_mode = model.decomp_mode;
11 model.decomp_mode = 2; % coefficients
12 [A_coeff,f_coeff] = model.operators(model,[]);
13 
14 N = reduced_data.N;
15 % for cell arrays:
16 %AN = lincomb_sequence(reduced_data.AN_comp, A_coeff);
17 %fN = lincomb_sequence(reduced_data.fN_comp, f_coeff);
18 AN = reshape(reduced_data.AN_comp * A_coeff,N,N);
19 fN = reduced_data.fN_comp * f_coeff;
20 
21 % solution variable:
22 %uh = femdiscfunc([],model_data.df_info);
23 %uh.dofs = A\r;
24 uN = AN\fN;
25 
26 % return results:
27 rb_sim_data.uN = uN;
28 
29 % plus error estimator
30 % res_norm = ... % residual norm
31 
32 if isfield(model, 'RB_error_indicator') ...
33  && strcmp(model.RB_error_indicator, 'estimator')
34 
35  % for elliptic compliant case, X-norm (=H10-norm) error estimator:
36  Q_r = size(reduced_data.G,1);
37  neg_auN_coeff = -uN * A_coeff';
38  %neg_auN_coeff = -A_coeff * uN';
39  res_coeff = [f_coeff; neg_auN_coeff(:)];
40  res_norm_sqr = res_coeff' * reduced_data.G * res_coeff;
41 
42  % direct computation (expensive):
43  if 0
44  % for debugging:
45  neg_auN_coeff = neg_auN_coeff(:);
46  Q_f = length(f_coeff);
47  res_norm_sqr_ff = f_coeff' * reduced_data.G(1:Q_f,1:Q_f) * f_coeff;
48  res_norm_sqr_fAu = f_coeff' * reduced_data.G(1:Q_f,(Q_f+1):end) * neg_auN_coeff;
49  res_norm_sqr_Auf = neg_auN_coeff' * reduced_data.G((Q_f+1):end,1:Q_f) * f_coeff;
50  res_norm_sqr_AuAu = neg_auN_coeff' * reduced_data.G((Q_f+1):end,(Q_f+1):end) * neg_auN_coeff;
51 
52  model_data = gen_model_data(model);
53  detailed_data = gen_detailed_data(model,model_data);
54  model.decomp_mode = 0;
55  [A,f] = model.operators(model,model_data);
56  model.decomp_mode = 2;
57  resAu = A * (detailed_data.RB(:,1:model.N) * uN);
58  resf = -f;
59  res = resAu + resf;
60  % residuum functional is res * v
61  % riesz representant: v_r' K v = (v_r,v) = res*v
62  % so res = K * v_r;
63  K = model.get_inner_product_matrix(detailed_data);
64  v_r = K \ res;
65  v_rAu = K \ resAu;
66  v_rf= K \ resf;
67  % res_norm_sqr = (v_r,v_r) = v_r' K v_r = v_r' * res;
68  res_norm_sqr2 = v_r' * res;
69  res_norm_sqr2_ff = v_rf' * resf;
70  res_norm_sqr2_fAu = v_rf' * resAu;
71  res_norm_sqr2_Auf = v_rAu' * resf;
72  res_norm_sqr2_AuAu = v_rAu' * resAu;
73  keyboard;
74  end;
75 
76  % prevent possibly negative numerical disturbances:
77  res_norm_sqr = max(res_norm_sqr,0);
78  res_norm = sqrt(res_norm_sqr);
79  % if the SCM is being used perform an online-phase and use the resulting
80  % lower bound. Otherwise use the old code.
81  if model.use_scm == 0
82  rb_sim_data.Delta = ...
83  res_norm/model.coercivity_alpha(model);
84  rb_sim_data.Delta_s = ...
85  res_norm_sqr/model.coercivity_alpha(model);
86  elseif model.use_scm == 1
87  if ~isfield(reduced_data, 'scm_offline_data')
88  error('There are no scm_offline_data to work with. They must be included in the reduced_data!')
89  end
90  constant_LB = scm_lower_bound(model, reduced_data);
91  rb_sim_data.Delta = ...
92  res_norm/constant_LB;
93  rb_sim_data.Delta_s = ...
94  res_norm_sqr/constant_LB;
95  end
96 
97 end % error estimation
98 
99 if model.compute_output_functional
100  % get operators
101  l_coeff = model.operators_output(model,reduced_data);
102 % lN = lincomb_sequence(reduced_data.lN_comp,l_coeff);
103  lN = reduced_data.lN_comp * l_coeff;
104  rb_sim_data.s = lN(:)' * rb_sim_data.uN;
105 end;
106 
107 model.decomp_mode = old_mode;
class representing a continous piecewise polynomial function of arbitrary dimension. DOFS correspond to the values of Lagrange-nodes.
Definition: femdiscfunc.m:17
function [ constant_LB , constant_UB ] = scm_lower_bound(model, reduced_data)
[constant_LB, constant_UB] = scm_lower_bound(model, reduced_data)