rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
rb_init_values_primal_dual.m
Go to the documentation of this file.
1 function a0 = rb_init_values_primal_dual(model, detailed_data)
2 %a0 = rb_init_values_primal_dual(model, detailed_data)
3 %
4 % copy of rb_init_values_default with the extension of the primal/dual
5 % case. Controlled via model.want_dual (being 1 or 0) the normal initial
6 % values or the riesz-representant of the current output functional is computed.
7 % In order of this function working properly model.operators_output has to
8 % be affinely decomposed.
9 %
10 % function computing the reduced basis initial values. If the
11 % decomposition mode is 'coefficients', the detailed_data are
12 % superfluous, can (and should for H-independence) be empty.
13 %
14 % Required fields of model
15 % init_values_algorithm: name of function for computing the
16 % detailed initvalues-DOF with arguments (grid, params)
17 % example: init_values_cog
18 %
19 % Function supports affine decomposition, i.e. different operation modes
20 % guided by optional field decomp_mode in params. See also the
21 % contents.txt for general explanation
22 %
23 
24 % Bernard Haasdonk 23.7.2006
25 % extension to primal/dual formulation by Dominik Garmatter 11.06 2012
26 
27 % determine affine_decomposition_mode as integer
28 decomp_mode = model.decomp_mode;
29 
30 if decomp_mode == 0 % complete: simple projection on RB
31  if model.want_dual
32  u0 = model.operators_output(model, detailed_data);
33  else
34  u0 = model.init_values_algorithm(model,detailed_data);
35  end
36  A = detailed_data.W;
37  a0 = u0' * A * detailed_data.RB;
38  %a0 = feval(params.inner_product_name, ...
39  % detailed_data.RB,u0,detailed_data.grid,params);
40  % equivalent for fv: a0 = (RB.*repmat(grid.A(:),1,Nmax))' * u0(:);
41 elseif decomp_mode == 1
42  Nmax = size(detailed_data.RB,2);
43  if model.want_dual
44  u0 = model.operators_output(model, detailed_data);
45  else
46  u0 = model.init_values_algorithm(model,detailed_data);
47  end
48  Q_u0 = length(u0);
49  a0 = cell(Q_u0,1);
50  a0(:) = {zeros(Nmax,1)};
51  % a0 : initial data projected on RB set: starting coefficients
52  A = detailed_data.W;
53  for q=1:Q_u0
54  a0{q} = u0{q}' * A * detailed_data.RB;
55  end
56  if model.debug && length(u0) > 1
57  if max(abs(detailed_data.RB * a0{1}'-u0{1}))>0.001
58  U0 = [u0{1},u0{2}];
59  U0_RB = [detailed_data.RB*a0{1}',detailed_data.RB*a0{2}'];
60  plot_params = [];
61  plot_params.plot = model.plot;
62  plot_params.title = 'U0 Components';
63  plot_sequence(U0,detailed_data.grid,plot_params);
64  plot_params.title = 'U0_RB';
65  plot_sequence(U0_RB,detailed_data.grid,plot_params);
66  error('rb initial data badly approximating initial data!!');
67  end
68  end
69 else % decomp_mode == 2 -> coefficients simply transfered from u0
70  if model.want_dual
71  u0 = model.operators_output(model, []);
72  else
73  u0 = model.init_values_algorithm(model, []);
74  end
75  a0 = u0;
76 end
77 
function a0 = rb_init_values_default(model, detailed_data)
function computing the reduced basis initial values. If the decomposition mode is coefficients...
function p = plot_sequence(varargin)
plotting a sequence of data slices on polygonal 2d grid (constructed from params if empty) and provid...
Definition: plot_sequence.m:17
function a0 = rb_init_values_primal_dual(model, detailed_data)
a0 = rb_init_values_primal_dual(model, detailed_data)