rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
rb_init_values_default.m
Go to the documentation of this file.
1 function a0 = rb_init_values_default(model,detailed_data)
2 %function a0 = rb_init_values_default(models,detailed_data)
3 % function computing the reduced basis initial values. If the
4 % decomposition mode is 'coefficients', the detailed_data are
5 % superfluous, can (and should for H-independence) be empty.
6 %
7 
8 % Bernard Haasdonk 23.7.2006
9 
10 % determine affine_decomposition_mode as integer
11 %model.decomp_mode = decomp_mode;
12 decomp_mode = model.decomp_mode;
13 
14 if decomp_mode == 0 % complete: simple projection on RB
15  Nmax = size(detailed_data.RB,2);
16  u0 = model.init_values_algorithm(model,detailed_data);
17  A = detailed_data.W;
18  a0 = u0' * A * detailed_data.RB;
19  %a0 = feval(params.inner_product_name, ...
20  % detailed_data.RB,u0,detailed_data.grid,params);
21  % equivalent for fv: a0 = (RB.*repmat(grid.A(:),1,Nmax))' * u0(:);
22 elseif decomp_mode == 1
23  Nmax = size(detailed_data.RB,2);
24  u0 = model.init_values_algorithm(model,detailed_data);
25  Q_u0 = length(u0);
26  a0 = cell(Q_u0,1);
27  a0(:) = {zeros(Nmax,1)};
28  % a0 : initial data projected on RB set: starting coefficients
29  A = detailed_data.W;
30  for q=1:Q_u0
31  a0{q} = u0{q}' * A * detailed_data.RB;
32  end;
33  if model.debug && length(u0) > 1
34  if max(abs(detailed_data.RB * a0{1}'-u0{1}))>0.001
35  U0 = [u0{1},u0{2}];
36  U0_RB = [detailed_data.RB*a0{1}',detailed_data.RB*a0{2}'];
37  plot_params = [];
38  plot_params.plot = model.plot;
39  plot_params.title = 'U0 Components';
40  plot_sequence(U0,detailed_data.grid,plot_params);
41  plot_params.title = 'U0_RB';
42  plot_sequence(U0_RB,detailed_data.grid,plot_params);
43  error('rb initial data badly approximating initial data!!');
44  end;
45  end;
46 % disp('halt in rb_init_values')
47 % keyboard;
48 else % decomp_mode== 2 -> coefficients simply transfered from u0
49  u0 = model.init_values_algorithm(model, []);
50  a0 = u0;
51 end;
52 
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