rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
rb_simulation.m
1 function rb_sim_data = rb_simulation(rmodel, reduced_data)
2 %function simulation_data = rb_simulation(rmodel, reduced_data)
3 % function, which performs a reduced basis online simulation for
4 % the parameter vector `\mu`, which is assumed to be set by set_mu()
5 %
6 % - allowed dependency of data: Nmax, N, M, mu
7 % - not allowed dependency of data: H
8 % - allowed dependency of computation: Nmax, N, M, mu
9 % - not allowed dependency of computation: H
10 % - Unknown at this stage: ---
11 %
12 % Parameters:
13 % reduced_data: reduced data object of type LinStat.ReducedData holding the reduced basis.
14 %
15 % Return values:
16 % rb_sim_data: struct holding the reduced simulation data.
17 
18 % B. Haasdonk 22.2.2011
19 
20 model = rmodel.detailed_model.descr;
21 
22 rb_sim_data =[];
23 
24 old_mode = model.decomp_mode;
25 model.decomp_mode = 2; % coefficients
26 
27 [A_coeff,f_coeff] = ...
28  model.operators(model,[]);
29 
30 AN = lincomb_sequence(reduced_data.AN_comp, A_coeff);
31 fN = lincomb_sequence(reduced_data.fN_comp, f_coeff);
32 
33 % solution variable:
34 %uh = femdiscfunc([],model_data.df_info);
35 %uh.dofs = A\r;
36 uN = AN\fN;
37 
38 % return results:
39 rb_sim_data.uN = uN;
40 
41 % plus error estimator
42 % res_norm = ... % residual norm
43 
44 % for elliptic compliant case, X-norm (=H10-norm) error estimator:
45 Q_r = size(reduced_data.G,1);
46 neg_auN_coeff = -A_coeff * uN';
47 res_coeff = [f_coeff; neg_auN_coeff(:)];
48 res_norm_sqr = res_coeff' * reduced_data.G * res_coeff;
49 
50 % direct computation (expensive):
51 if 0
52  % for debugging:
53  neg_auN_coeff = neg_auN_coeff(:);
54  Q_f = length(f_coeff);
55  res_norm_sqr_ff = f_coeff' * reduced_data.G(1:Q_f,1:Q_f) * f_coeff;
56  res_norm_sqr_fAu = f_coeff' * reduced_data.G(1:Q_f,(Q_f+1):end) * neg_auN_coeff;
57  res_norm_sqr_Auf = neg_auN_coeff' * reduced_data.G((Q_f+1):end,1:Q_f) * f_coeff;
58  res_norm_sqr_AuAu = neg_auN_coeff' * reduced_data.G((Q_f+1):end,(Q_f+1):end) * neg_auN_coeff;
59 
60  model_data = gen_model_data(model);
61  detailed_data = gen_detailed_data(model,model_data);
62  model.decomp_mode = 0;
63  [A,f] = model.operators(model,model_data);
64  model.decomp_mode = 2;
65  resAu = A * (detailed_data.RB(:,1:model.N) * uN);
66  resf = -f;
67  res = resAu + resf;
68  % residuum functional is res * v
69  % riesz representant: v_r' K v = (v_r,v) = res*v
70  % so res = K * v_r;
71  K = model.get_inner_product_matrix(detailed_data);
72  v_r = K \ res;
73  v_rAu = K \ resAu;
74  v_rf= K \ resf;
75  % res_norm_sqr = (v_r,v_r) = v_r' K v_r = v_r' * res;
76  res_norm_sqr2 = v_r' * res;
77  res_norm_sqr2_ff = v_rf' * resf;
78  res_norm_sqr2_fAu = v_rf' * resAu;
79  res_norm_sqr2_Auf = v_rAu' * resf;
80  res_norm_sqr2_AuAu = v_rAu' * resAu;
81  keyboard;
82 end;
83 
84 % prevent possibly negative numerical disturbances:
85 res_norm_sqr = max(res_norm_sqr,0);
86 res_norm = sqrt(res_norm_sqr);
87 rb_sim_data.res_norm = res_norm;
88 rb_sim_data.Delta = ...
89  res_norm/model.coercivity_alpha(model);
90 rb_sim_data.Delta_s = ...
91  res_norm_sqr/model.coercivity_alpha(model);
92 
93 if model.compute_output_functional
94  % get operators
95  l_coeff = ...
96  model.operators_output(model,reduced_data);
97  lN = ...
98  lincomb_sequence(reduced_data.lN_comp,l_coeff);
99  rb_sim_data.s = lN(:)' * rb_sim_data.uN;
100  % rb_sim_data.Delta_s = ...;
101 end;
102 
103 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
Reduced basis implementation for linear stationary PDEs.
Reduced data implementation for linear stationary problems with finite element discretizations.
Definition: ReducedData.m:18