rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
lin_evol_opt_rb_init_values_separate_bases.m
1 function [a0,c0] = lin_evol_opt_rb_init_values_separate_bases(model,detailed_data)
2 %function a0 = lin_evol_opt_rb_init_values_separate_bases(models,detailed_data)
3 %
4 % function computing the reduced basis initial values for the solution (a0) and the
5 % derivative solutions (c0). If the
6 % decomposition mode is 'coefficients', the detailed_data are
7 % superfluous, can (and should for H-independence) be empty.
8 %
9 % required fields of model
10 % init_values_algorithm: name of function for computing the
11 % detailed initvalues-DOF with arguments (grid, params)
12 % example: init_values_cog
13 %
14 % c0 is a cell array
15 %
16 % Function supports affine decomposition, i.e. different operation modes
17 % guided by optional field decomp_mode in params. See also the
18 % contents.txt for general explanation
19 %
20 
21 % Markus Dihlmann 30.03.2011
22 
23 % determine affine_decomposition_mode as integer
24 decomp_mode = model.decomp_mode;
25 
26 if decomp_mode == 0 % complete: simple projection on RB
27  %Nmax = size(detailed_data.RB,2);
28  u0 = model.init_values_algorithm(model,detailed_data);
29  A = detailed_data.W;
30  a0 = u0' * A * detailed_data.RB;
31 
32  if model.compute_derivative_info
33  RB_der = detailed_data.RB_der;
34  p = sum(model.compute_derivative_indices);
35  der_indices = find(model.compute_derivative_indices);
36  c0=cell(p,1);
37  for i=1:p
38  c0{i} = u0' * A * RB_der{der_indices(i)};
39  end
40  else
41  c0=[];
42  end
43 
44 elseif decomp_mode == 1
45  Nmax = size(detailed_data.RB,2);
46  u0 = model.init_values_algorithm(model,detailed_data);
47  Q_u0 = length(u0);
48  a0 = cell(Q_u0,1);
49  a0(:) = {zeros(Nmax,1)};
50  % a0 : initial data projected on RB set: starting coefficients
51  A = detailed_data.W;
52  for q=1:Q_u0
53  a0{q} = u0{q}' * A * detailed_data.RB;
54  end;
55 
56  % c0 :initial data projection on RB_derivatives
57  if model.compute_derivative_info
58  RB_der = detailed_data.RB_der;
59  if isfield(model,'separate_bases_derivative_nr')
60  p=model.separate_bases_derivative_nr;
61  c0=cell(p,1);
62  c0{p} = cell(Q_u0,1);
63  c0{p}(:) = {zeros(size(RB_der{p},2),1)};
64  for q=1:Q_u0
65  c0{p}{q} = u0{q}' * A * RB_der{p};
66  end;
67  else
68  p = length(RB_der);
69  c0=cell(p,1);
70  for i=1:p
71  c0{i} = cell(Q_u0,1);
72  c0{i}(:) = {zeros(size(RB_der{i},2),1)};
73  for q=1:Q_u0
74  c0{i}{q} = u0{q}' * A * RB_der{i};
75  end;
76  end
77  end
78 
79  else
80  c0={0};
81  end
82 else % decomp_mode== 2 -> coefficients simply transfered from u0
83  u0 = model.init_values_algorithm(model, []);
84  a0 = u0;
85  if model.compute_derivative_info
86  c0 = model.rb_derivative_init_values_coefficients(model);
87  %filter out coefficients actually needed
88  %der_indices = find(model.compute_derivative_indices);
89  %c0 = c0(der_indices,:);
90  else
91  c0=0;
92  end
93 end;
94 
95