rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
lin_evol_opt_rb_derivative_simulation_separate_bases.m
1 function simulation_data = lin_evol_opt_rb_derivative_simulation_separate_bases(model, reduced_data)
2 %function simulation_data = lin_evol_opt_rb_derivative_simulation_separate_bases(model, reduced_data)
3 %
4 %performs in parallel a reduced simulation and calculation of the
5 %derivative @f$\partial_{\mu_i}u@f$
6 %
7 % This function is an extension of the \\c lin_evol_rb_simulation function.
8 % Except that in this method the time step is not included in the
9 % operators, but the time integration is conducted here by an explicit Euler.
10 % In parallel to the reduced basis online simulation a calculation of the
11 % derivative @f$\partial_{\mu_i}u@f$. The derivatives are approximated in
12 % different reduced spaces than the solution.
13 %
14 % It is assumed that the wanted mu is already set in the model.
15 % (setmu(model,mu))
16 %
17 % The calculation of the derivative is made in parallel by solving in each
18 % time step the ODE @f$\partial_t \partial_{\mu_i} a + L_E \partial_{\mu_i}
19 % a + \sum \partial_{\mu_i}(\Theta^q(\mu))L^q a -\partial_{mu_i} b(x,t,\mu) =
20 % 0@f$ plus derivative of the initial conditions.
21 % All information calculating the derivative is already contained in
22 % reduced_data or is already calculated for the normal rb_simulation except
23 % @f$\partial_{\mu_i}\Theta(\mu)@f$ and @f$\partial_{\mu_i}\Theta_b @f$
24 % which are obtained calling the field \\c model.rb_derivative_operators.
25 % The field \\c model.rb_derivative_init_values points to a method
26 % providing derivative initial values.
27 %
28 % allowed dependency of data: Nmax, N, M, mu
29 % not allowed dependency of data: H
30 % allowed dependency of computation: Nmax, N, M, mu
31 % not allowed dependency of computation: H
32 %
33 % Required fields of model
34 % mu_names : the cell array of names of mu-components and
35 % for each of these strings, a corresponding
36 % field in model is expected.
37 % T : end-time of simulation
38 % nt : number of timesteps to compute
39 % error_norm : 'l2' or 'energy'
40 % L_I_inv_norm_bound: upper bound on implicit operator inverse norm
41 % constant in time, a single scalar
42 % L_E_norm_bound: upper bounds on explicit operator
43 % constant in time, a single scalar
44 % L_E_der_norm_bound: upper bound on explicit derivative operator
45 % constant in time, a single scalar
46 % L_I_der_norm_bound: upper bound on implicit derivative operator
47 % constant in time, a single scalar
48 % energy_norm_gamma: gamma >= 0 defining the weight in the energy norm
49 % coercivity_bound_name : name of the function, which can
50 % computes a lower bound on the coercivity, e.g.
51 % fv_coercivity_bound
52 % compute_derivative_info: 0 if no derivative information is needed
53 % 1 if derivative information is needed
54 %
55 % plus fields required by coercivity_bound_name.m
56 %
57 % optional fields of model:
58 % data_const_in_time : if this flag is set, then only operators
59 % for first time instance are computed
60 % name_output_functional: if this field is existent, then an
61 % output estimation is performed and error.estimtations
62 %
63 % generated fields of simulation_data:
64 % a: time sequence of solution coefficients, columns are
65 % 'a(:,k)' = `a^(k-1)`
66 % c: matrix(3-dimensional) of time secquence representing the derivative of a for
67 % @f$\mu_i@f$
68 % Delta:time sequence of `L^2`-posteriori error estimates
69 % 'Delta(k)' = `\Delta^{k-1}_N`
70 % or energy-norm-posterior error estimates
71 % 'Delta_energy(k)' = `\bar \Delta^{k-1}_N`
72 % depending on the field "error_norm" in model.
73 %
74 % if model.name_output_functional is set, then additionally, a
75 % sequence of output estimates 's(U(:,))' and error bound Delta_s is returned
76 %
77 % see the ***_gen_reduced_data() routine for specifications of the
78 % fields of reduced_data
79 
80 % Markus Dihlmann 25.03.2011
81 
82 if model.verbose >= 10
83  if model.compute_derivative_info
84  printf('performing simulation and derivative calculation for mu = %s', mat2str(get_mu(model)));
85  else
86  printf('performing simulation');
87  end
88 end;
89 
90 if (~isequal(model.error_norm,'l2')) && ...
91  (~isequal(model.error_norm,'energy'))
92  error('error_norm unknown!!');
93 end;
94 
95 %needed for derivative information
96 if ~isfield(model,'optimization')
97  disp('Model has no field optimization.')
98  model.optimization =[];
99 end
100 if isfield(model.optimization,'params_to_optimize')
101  indx_mu_i = find(model.optimization.params_to_optimize); %indexes i of \mu_i for which derivative information is needed
102 else
103  indx_mu_i = 1:length(get_mu(model));
104 end
105 nr_indx_mu_i= length(indx_mu_i); %nr of parameters to be optimized
106 
107 if isfield(model,'compute_derivative_indices')
108  indx_derivatives = find(model.compute_derivative_indices);
109 else
110  indx_derivatives = 1:length(get_mu(model));
111 end
112 
113 %cgrid = grid_geometry(params);
114 nRB = length(reduced_data.a0{1});
115 a = zeros(nRB,model.nt+1); % matrix of RB-coefficients
116 Delta = zeros(1,model.nt+1); % vector of error estimators
117 model.dt = model.T/model.nt;
118 
119 %debug
120 res_u = zeros(1,model.nt+1);
121 res_u_der = zeros(1,model.nt+1);
122 %end debug
123 
124 
125 if model.compute_derivative_info
126  c = cell(nr_indx_mu_i,1);
127  c_0 = cell(nr_indx_mu_i,1);
128  nRB_der = zeros(1,nr_indx_mu_i);
129  Delta_der = zeros(nr_indx_mu_i, model.nt+1); % vector of derivative error estimators
130  for i=1:nr_indx_mu_i
131  nRB_der(i)=length(reduced_data.c0{indx_mu_i(i)}{1});
132  c{i} = zeros(nRB_der(i), model.nt+1); %cell-array of RB-derivative-coefficients
133  end
134 end
135 
136 
137 % initial data projection and linear combination
138 model.decomp_mode = 2;
139 sa0 = rb_init_values(model,[]);
140 a0 = lincomb_sequence(reduced_data.a0,sa0);
141 a(:,1) = a0;
142 
143 if model.compute_derivative_info
144  sc_0 = model.rb_derivative_init_values_coefficients(model);
145  for i=1:nr_indx_mu_i
146  c_0{i} = lincomb_sequence(reduced_data.c0{indx_mu_i(i)},sc_0(indx_mu_i(i),:)');
147  c{i}(:,1) = c_0{i};
148  end
149 
150  %initialisation of error matrices
151  %initialize cells
152  L_E_dd = cell(nr_indx_mu_i,1);
153  L_I_dd = cell(nr_indx_mu_i,1);
154  dL_E_sd = cell(nr_indx_mu_i,1);
155  dL_I_sd = cell(nr_indx_mu_i,1);
156  db = cell(nr_indx_mu_i,1);
157  K_E = cell(nr_indx_mu_i,1);
158  K_I = cell(nr_indx_mu_i,1);
159  K_EE = cell(nr_indx_mu_i,1);
160  %K_Eb = cell(nr_indx_mu_i,1);
161  %K_bb = cell(nr_indx_mu_i,1);
162  K_II = cell(nr_indx_mu_i,1);
163  %K_Ib = cell(nr_indx_mu_i,1);
164  K_IE = cell(nr_indx_mu_i,1);
165  K_EdEd = cell(nr_indx_mu_i,1);
166  K_IdId = cell(nr_indx_mu_i,1);
167  K_bdbd = cell(nr_indx_mu_i,1);
168  K_Ed = cell(nr_indx_mu_i,1);
169  K_Id = cell(nr_indx_mu_i,1);
170  K_bd = cell(nr_indx_mu_i,1);
171  K_IEd = cell(nr_indx_mu_i,1);
172  K_IId = cell(nr_indx_mu_i,1);
173  K_Ibd = cell(nr_indx_mu_i,1);
174  K_EEd = cell(nr_indx_mu_i,1);
175  K_EId = cell(nr_indx_mu_i,1);
176  K_Ebd = cell(nr_indx_mu_i,1);
177  K_EdId = cell(nr_indx_mu_i,1);
178  K_Edbd = cell(nr_indx_mu_i,1);
179  K_Idbd = cell(nr_indx_mu_i,1);
180 
181  %fix size for all b-dependent matrices to prevent errors in
182  %approximation error calculation
183  for i=1:nr_indx_mu_i
184  K_bd{i} = zeros(1,nRB_der(i));
185  K_Ibd{i} = zeros(nRB_der(i),1);
186  K_Ebd{i} = zeros(nRB_der(i),1);
187  K_Edbd{i} = zeros(nRB_der(i),1);
188  K_Idbd{i} = zeros(nRB,1);
189  K_EId{i} = zeros(nRB_der(i),nRB);
190  K_EdId{i} = zeros(nRB,nRB);
191  K_I{i} = 0;
192  K_II{i} = 0;
193  K_IE{i} = 0;
194  K_IdId{i} = 0;
195  K_Id{i} = zeros(nRB_der(i),nRB);
196  K_IEd{i} = zeros(nRB_der(i),nRB);
197  K_IId{i} = zeros(nRB_der(i),nRB);
198 
199  end
200 
201 end
202 
203 
204 model.decomp_mode =2;
205 % loop over time steps: computation of a(t+1)==a^t
206 for t = 1:model.nt
207  model.t = (t-1)*model.dt;
208  if model.verbose >= 20
209  disp(['entered time-loop step ',num2str(t)]);
210  end;
211 
212  % linear combination of all quantities
213  % only once, if data is const in time
214  if (t==1) || (~model.data_const_in_time)
215  if model.compute_derivative_info% NEU
216  [sLL_I, sLL_E, sbb, sM_E, sM_b, sM_EE, sM_Eb, sM_bb, sM_I, sM_II, sM_IE, sM_Ib, ...
217  sL_E_dd, sL_I_dd, sdL_E_sd, sdL_I_sd, sdb,...
218  sK_E, sK_I, sK_EE, sK_II, sK_IE,...
219  sK_EdEd, sK_IdId, sK_bdbd, sK_Ed, sK_Id, sK_bd, sK_IEd, sK_IId, sK_Ibd, sK_EEd, ...
220  sK_EId, sK_Ebd, sK_EdId, sK_Edbd, sK_Idbd] = rb_operators(model,[]);
221  else
222  [sLL_I, sLL_E, sbb, sM_E, sM_b, sM_EE, sM_Eb, sM_bb, sM_I, sM_II, sM_IE, sM_Ib] ...
223  = rb_operators(model,[]);
224  end
225 
226  LL_I = lincomb_sequence(reduced_data.LL_I,sLL_I);
227  LL_E = lincomb_sequence(reduced_data.LL_E,sLL_E);
228  bb = lincomb_sequence(reduced_data.bb,sbb);
229  M_E = lincomb_sequence(reduced_data.M_E,sM_E);
230  M_b = lincomb_sequence(reduced_data.M_b,sM_b);
231  M_EE = lincomb_sequence(reduced_data.M_EE,sM_EE);
232  M_Eb = lincomb_sequence(reduced_data.M_Eb,sM_Eb);
233  M_bb = lincomb_sequence(reduced_data.M_bb,sM_bb);
234  M_I = lincomb_sequence(reduced_data.M_I,sM_I);
235  M_II = lincomb_sequence(reduced_data.M_II,sM_II);
236  M_Ib = lincomb_sequence(reduced_data.M_Ib,sM_Ib);
237  M_IE = lincomb_sequence(reduced_data.M_IE,sM_IE);
238 
239 
240 %
241 % if model.data_const_in_time
242 % % inverse of implicit matrix! L_I' = Id, L_E' = L_I^(-1) *
243 % % L_E, bb = L_I^(-1) bb
244 % LL_E = (speye(size(LL_I)) - LL_I) \ LL_E;
245 % bb = (speye(size(LL_I)) - LL_I) \ bb;
246 % LL_I = zeros(size(LL_I));
247 % end;
248  end;
249 
250 
251  % solve (I-dt*LL_I) a(:,t+1) = (I+dt*LL_E) * a(:,t) + bb
252  rhs = (speye(size(LL_E)) + model.dt*LL_E) * a(:,t) + model.dt*bb;
253 
254  % warning('this does not work for pure space operators (independent of delta t). In that case use the commented line below.');
255  %rhs = a(:,t) + model.dt * (LL_E * a(:,t) + bb);
256  % check whether pure explicit problem:
257  if isequal(LL_I, zeros(size(LL_I)))
258  a(:,t+1) = rhs;
259  %debug 28.10.10: folgende zeile mit reingenommen, damit
260  %res_norm_times_dt_sqr ein skalar wird
261  M_Ib=zeros(nRB,1);
262  % end debug 28.10.10
263  else % solve linear system
264  a(:,t+1) = (speye(size(LL_I)) - model.dt*LL_I)\rhs;
265  end;
266 
267 
268  % compute error estimate recursively
269  % Delta^k := |L_I^(k-1)|^-1 * (res_norm(k-1)+
270  % |L_E^(k-1)|*Delta^(k-1))
271  res_norm_times_dt_sqr = a(:,t+1)'*a(:,t+1) - 2*a(:,t+1)' * a(:,t) + a(:,t)'*a(:,t) ...
272  +2*model.dt*( a(:,t)'*M_E*a(:,t) - a(:,t)'*M_E*a(:,t+1) ...
273  +M_b*a(:,t) - M_b*a(:,t+1) ...
274  +a(:,t+1)'*M_I*a(:,t) - a(:,t+1)'*M_I*a(:,t+1)) ...
275  +((model.dt)^2)* ( a(:,t)'*M_EE*a(:,t) + a(:,t+1)'*M_II*a(:,t+1) + M_bb ...
276  +2*( a(:,t+1)'*M_IE*a(:,t) +a(:,t)'*M_Eb + a(:,t+1)'*M_Ib));
277 
278 
279 
280  % ensure real estimators (could be complex due to numerics)
281  if res_norm_times_dt_sqr>=0
282  res_norm_times_dt = sqrt(res_norm_times_dt_sqr);
283  else
284 % keyboard;
285  disp('residual < 0')
286  res_norm_times_dt = 0;
287  end;
288 
289  %debug
290  res_u(t) = res_norm_times_dt;
291  %end debug
292 
293  if isequal(model.error_norm,'l2')
294  Delta(t+1) = res_norm_times_dt + model.L_E_norm_bound * Delta(t);
295  else
296  % only sum up the squares of the residuals, multiplication with coeff
297  % and squareroots are taken at the end.
298  keyboard;
299  Rkplus1sqr = max(res_norm_sqr/(params.dt.^2), 0);
300  Delta(t+1) = Delta(t)+Rkplus1sqr;
301  end;
302 
303 
304 
305 
306 
307 
308  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309  %Calculation of derivative \partial_{\mu}a
310  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311  if model.compute_derivative_info
312  model.decomp_mode=2;
313 
314  if (t==1) || (~model.data_const_in_time)
315  %[sLi,sLe,sb] = model.rb_derivative_operators_coefficients_ptr(model);
316  %sLe = -sLe;
317 
318  %LL_E_derived=zeros(size(reduced_data.LL_E{1},1),size(reduced_data.LL_E{1},2),nr_indx_mu_i);
319  %bb_derived=zeros(length(reduced_data.bb{1}),nr_indx_mu_i);
320 
321  %LL_E stays the same
322  if model.compute_derivative_info
323  %[sdL_I_sd,sdL_E_sd,sdb] = model.rb_derivative_operators_coefficients_ptr(model);
324  for i=1:nr_indx_mu_i
325  if ~isempty(reduced_data.LL_I)
326  %dL_I_sd{i}=zeros(size(reduced_data.dL_I_sd{indx_mu_i(i)}{1},1),size(reduced_data.dL_I_sd{indx_mu_i(i)}{1},2),nr_indx_mu_i);
327  %L_I_dd{i}=zeros(size(reduced_data.L_I_dd{indx_mu_i(i)}{1},1),size(reduced_data.L_I_dd{indx_mu_i(i)}{1},2),nr_indx_mu_i);
328  else
329  dL_I_sd{i}=zeros(nRB_der(i),nRB);
330  end
331 
332  if ~isempty(sK_I) %only do the linear combination if the coefficients sLi are not empty
333  L_I_dd{i}(:,:) = lincomb_sequence(reduced_data.L_I_dd{indx_mu_i(i)}, sL_I_dd(:,:));
334  dL_I_sd{i}(:,:) = lincomb_sequence(reduced_data.dL_I_sd{indx_mu_i(i)}, sdL_I_sd(:,indx_mu_i(i))); K_Ibd{i} = lincomb_sequence(reduced_data.K_Ibd{i} ,sK_Ibd(:,i));
335  K_EId{i} = lincomb_sequence(reduced_data.K_EId{indx_mu_i(i)} ,sK_EId(:,indx_mu_i(i)));
336  K_EdId{i} = lincomb_sequence(reduced_data.K_EdId{indx_mu_i(i)},sK_EdId(:,indx_mu_i(i)));
337  K_Idbd{i} = lincomb_sequence(reduced_data.K_Idbd{indx_mu_i(i)},sK_Idbd(:,indx_mu_i(i)));
338  K_I{i} = lincomb_sequence(reduced_data.K_I{indx_mu_i(i)},sK_I);
339  K_II{i} = lincomb_sequence(reduced_data.K_II{indx_mu_i(i)},sK_II);
340  K_IE{i} = lincomb_sequence(reduced_data.K_IE{indx_mu_i(i)},sK_IE);
341  K_IdId{i} = lincomb_sequence(reduced_data.K_IdId{indx_mu_i(i)},sK_IdId(:,indx_mu_i(i)));
342  K_Id{i} = lincomb_sequence(reduced_data.K_Id{indx_mu_i(i)} ,sK_Id(:,indx_mu_i(i)));
343  K_IEd{i} = lincomb_sequence(reduced_data.K_IEd{indx_mu_i(i)} ,sK_IEd(:,indx_mu_i(i)));
344  K_IId{i} = lincomb_sequence(reduced_data.K_IId{indx_mu_i(i)} ,sK_IId(:,indx_mu_i(i)));
345  end
346 
347  L_E_dd{i}(:,:) = lincomb_sequence(reduced_data.L_E_dd{indx_mu_i(i)}, sL_E_dd(:,:));
348  dL_E_sd{i}(:,:) = lincomb_sequence(reduced_data.dL_E_sd{indx_mu_i(i)}, sdL_E_sd(:,indx_mu_i(i)));
349  db{i} = lincomb_sequence(reduced_data.db{indx_mu_i(i)}, sdb(:,indx_mu_i(i)));
350  K_E{i} = lincomb_sequence(reduced_data.K_E{indx_mu_i(i)},sK_E);
351  %K_b = lincomb_sequence(reduced_data.K_b,sK_b);
352  K_EE{i} = lincomb_sequence(reduced_data.K_EE{indx_mu_i(i)},sK_EE);
353  %K_Eb = lincomb_sequence(reduced_data.K_Eb,sK_Eb);
354  %K_bb = lincomb_sequence(reduced_data.K_bb,sK_bb);
355  %K_Ib = lincomb_sequence(reduced_data.K_Ib,sK_Ib);
356  K_EdEd{i} = lincomb_sequence(reduced_data.K_EdEd{indx_mu_i(i)},sK_EdEd(:,indx_mu_i(i)));
357  K_bdbd{i} = lincomb_sequence(reduced_data.K_bdbd{indx_mu_i(i)},sK_bdbd(:,indx_mu_i(i)));
358  K_Ed{i} = lincomb_sequence(reduced_data.K_Ed{indx_mu_i(i)} ,sK_Ed(:,indx_mu_i(i)));
359  K_bd{i} = lincomb_sequence(reduced_data.K_bd{indx_mu_i(i)} ,sK_bd(:,indx_mu_i(i)));
360  K_EEd{i} = lincomb_sequence(reduced_data.K_EEd{indx_mu_i(i)} ,sK_EEd(:,indx_mu_i(i)));
361  K_Ebd{i} = lincomb_sequence(reduced_data.K_Ebd{indx_mu_i(i)} ,sK_Ebd(:,indx_mu_i(i)));
362  K_Edbd{i} = lincomb_sequence(reduced_data.K_Edbd{indx_mu_i(i)},sK_Edbd(:,indx_mu_i(i)));
363 
364  end
365  end
366 
367  end
368 
369  % solve d/dt c(:,:,i) = LL_E * c(:,:,i) + LL_E_derived a() +
370  % bb_derived
371  for i=1:nr_indx_mu_i
372  rhs_der = (speye(size(L_E_dd{i})) + model.dt*L_E_dd{i}) * c{i}(:,t) + model.dt*dL_E_sd{i}* a(:,t) ...
373  + model.dt*dL_I_sd{i}* a(:,t+1) + model.dt*db{i};
374 
375  % check whether pure explicit problem:
376  if isequal(LL_I, zeros(size(LL_I)))
377  c{i}(:,t+1) = rhs_der;
378  else %solve linear system
379  c{i}(:,t+1) = (speye(size(L_I_dd{i})) - model.dt*L_I_dd{i})\rhs_der;
380  end
381 
382 
383  %compute error estrimator recuresivly
384  res_norm_der_times_dt_sqr = c{i}(:,t+1)'*c{i}(:,t+1) ...
385  + c{i}(:,t)'*c{i}(:,t) - 2*c{i}(:,t+1)'*c{i}(:,t) ...
386  + 2*model.dt*(-c{i}(:,t+1)'*K_I{i}*c{i}(:,t+1) - c{i}(:,t)'*K_E{i}*c{i}(:,t+1) ...
387  -a(:,t)'*K_Ed{i}*c{i}(:,t+1) - c{i}(:,t+1)'*K_Id{i}*a(:,t+1)...
388  -c{i}(:,t+1)'*K_bd{i}' + c{i}(:,t+1)'*K_I{i}*c{i}(:,t) ...
389  +c{i}(:,t)'*K_E{i}*c{i}(:,t) + a(:,t)'*K_Ed{i}*c{i}(:,t) ...
390  +c{i}(:,t)'*K_Id{i}*a(:,t+1) + c{i}(:,t)'*K_bd{i}' ) ... %13.10.10: bei M_bd aufpassen, nur ein Doppelpunkt?!
391  + ((model.dt)^2) * (c{i}(:,t+1)'*K_II{i}*c{i}(:,t+1) + c{i}(:,t)'*K_EE{i}*c{i}(:,t) ...
392  + a(:,t)'*K_EdEd{i}*a(:,t) + a(:,t+1)'*K_IdId{i}*a(:,t+1)...
393  + K_bdbd{i} + 2*c{i}(:,t+1)'*K_IE{i}*c{i}(:,t) ...
394  + 2*c{i}(:,t+1)'*K_IEd{i}*a(:,t) + 2*c{i}(:,t+1)'*K_IId{i}*a(:,t+1)...
395  + 2*c{i}(:,t+1)'*K_Ibd{i} + 2*c{i}(:,t)'*K_EEd{i}*a(:,t) ...
396  + 2*c{i}(:,t)'*K_EId{i}*a(:,t+1) + 2*c{i}(:,t)'*K_Ebd{i} ...
397  + 2*a(:,t)'*K_EdId{i}*a(:,t+1) + 2*a(:,t)'*K_Edbd{i}...
398  + 2*a(:,t+1)'*K_Idbd{i} );
399 
400 
401 
402 
403  % ensure real estimators (could be complex due to numerics)
404  if res_norm_der_times_dt_sqr>=0
405  res_norm_der_times_dt = sqrt(res_norm_der_times_dt_sqr);
406  else
407  res_norm_der_times_dt = 0;
408  end;
409 
410  %debug
411  res_u_der(t) = res_norm_der_times_dt;
412  %end debug
413 
414  if isequal(model.error_norm,'l2')
415  if model.time_const
416  t_old = model.t;
417  model.t=0;
418  end
419  Delta_der(i,t+1) = model.L_E_norm_bound*Delta_der(i,t) + model.L_E_der_norm_bound(model,indx_derivatives(i))*Delta(t) ...
420  + model.L_I_der_norm_bound(model,indx_derivatives(i))*Delta(t+1) + res_norm_der_times_dt ;
421  if model.time_const
422  model.t=t_old;
423  end
424  end
425 
426 
427 
428  end %for i=1:nr_indx_mu
429  end %if model.compute_derivative_info
430 end;
431 
432 if isequal(model.error_norm,'energy')
433  % now perform scaling and squareroot of energy-error-estimate:
434  alpha = model.coercivity_bound_ptr(model);
435  if max(model.L_E_norm_bound>1) || (alpha == 0)
436  % no reasonable estimation possible
437  Delta(:) = nan;
438  else
439  C = (sqrt(1-model.L_E_norm_bound.^2)+1) * 0.5;
440  Coeff = model.dt /(4*alpha*C*(1-model.energy_norm_gamma * C));
441  Delta = sqrt(Delta * Coeff);
442  end;
443 end;
444 
445 % return simulation result
446 simulation_data = [];
447 simulation_data.a = a;
448 simulation_data.Delta = Delta;
449 %simulation_data.Delta_rel = Delta./max(u_N_norm);
450 simulation_data.LL_I = LL_I;
451 simulation_data.LL_E = LL_E;
452 
453 %debug
454 simulation_data.res_u = res_u;
455 simulation_data.res_u_der = res_u_der;
456 %end debug
457 
458 if model.compute_derivative_info
459  simulation_data.Delta_der = Delta_der;
460  simulation_data.c = c;
461  %for i=1:size(Delta_der,1)
462  % simulation_data.Delta_der_rel(i,:) = Delta_der(i,:)./max(u_N_der_norm(i,:));
463  %end
464 end
465 
466 if isfield(model,'name_output_functional')
467  if isequal(model.error_norm,'l2')
468 
469  s = reduced_data.s_RB'*a;
470  if isfield(model,'s_l2norm')
471  Delta_s = model.s_l2norm * Delta; %war ursprünglich in reduced_data.s_l2norm
472  simulation_data.Delta_s = Delta_s(:);
473  else
474  if (model.verbose >=10)
475  disp('warning: no L2_norm for output defined in lin_evol_rb_simulation...')
476  end
477  end
478  simulation_data.s = s(:);
479 
480  if model.compute_derivative_info
481  %derivative output and error estimation of gradient
482  %sum=0;%for l2-norm
483  for i=1:length(c)
484  s_der{i} = c{i}(:,:)'*reduced_data.s_RB_der{indx_mu_i(i)};
485  %sum = sum + max(Delta_der(i,:))^2;
486  end
487  simulation_data.s_der = s_der;
488  simulation_data.Delta_s_grad = model.s_l2norm * max(Delta_der,[],2);%sqrt(sum); %Gradient error bound
489 
490  end
491 
492  else
493  error(['output estimation not implemented concerning energy-norm.' ...
494  ' choose l2 as error_norm!']);
495  end;
496 end;
497 
498 
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
Definition: verbose.m:17