rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
t_part_initial_cond_POD.m
1 function U0=t_part_initial_cond_POD(model, detailed_data)
2 %function U0=t_part_initial_cond_POD(model, detailed_data)
3 %
4 % function calculates the final time step solutions for all parameters used for generating the
5 % forgoing partition basis.
6 % Then a POD over all these solutions is done and the
7 % model.basis_vector_overlap first modes are taken a initial basis for the
8 % new partition.
9 
10 % Markus Dihlmann 25.02.2011
11 
12 disp('calculating POD of initial data training set')
13 
14 U0=[];
15 
16 t_part_ind = model.t_part_for_simulation - 1;
17 if t_part_ind == 0
18  U0 = RB_init_data_basis(model, detailed_data);
19 else
20 
21  mu_set = detailed_data.t_part_detailed_data{t_part_ind}.RB_info.mu_sequence;
22 
23  mus_done = [];
24 
25  for i = 1:size(mu_set,2)
26  if ~isnan(mu_set(1,i))
27  if ~ispartof(mu_set(:,i), mus_done)
28  %detailed_simulation of mu
29  mus_done = [mus_done, mu_set(:,i)];
30  model = set_mu(model, mu_set(:,i));
31  sim_data = detailed_simulation(model, detailed_data);
32 
33  U_last = sim_data.U(:,end);
34 
35  U0 = [U0, U_last];
36  end
37  end
38  end
39  U_init = U0(:,1);
40  U0 = PCA_fixspace(U0(:,2:end), U_init, detailed_data.W, model.basis_vector_overlap);
41  U0 = [U_init, U0];
42 
43 end
44 
45 end
46 
47 
48 function ret = ispartof(mu, M)
49 
50  ret =0;
51  num_el = size(M,1);
52  len=size(M,2);
53  l=1;
54  while (ret==0)&&(l<=len)
55 
56  v=(M(:,l)==mu);
57  if sum(v)==num_el
58  ret =1 ;
59  end
60  l=l+1;
61  end
62 end