rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
t_part_gen_reduced_data.m
1 function reduced_data = t_part_gen_reduced_data(model, detailed_data)
2 %function reduced_data = t_part_gen_reduced_data(model, detailed_data)
3 %
4 % function generating the reduced data for a t-part model.
5 % To the normal reduced data of the base model a transfer matrix T is
6 % generated, which projects the coefficients from the foregoing reduced
7 % space to the next.
8 %
9 % Required fields of detailed_data:
10 % t_part_detailed_data: the detailed data including the reduced
11 % bases from the t-partitions
12 %
13 % Generated fields of reduced_data:
14 % reduced_data_t_partitions: Cell array containing the reduced data
15 % for every t-partition.
16 %
17 %
18 
19 % Markus Dihlmann 15.02.2010
20 
21 if ~isfield(model,'t_part_in_basis_generation')
22  model.t_part_in_basis_generation =0;
23 end
24 
25 if ~isfield(model,'transition_model')
26  model.transition_model =0;
27 end
28 
29 
30 if model.t_part_in_basis_generation
31  %model is in basis generation mode
32  %means that the detailed_data RB field has to be added temporarily as a
33  %new field of tp_detailed_data
34  if isfield(detailed_data,'t_part_detailed_data')
35  %we are at least in the second domain in basis generation
36  tp_detailed_data = detailed_data.t_part_detailed_data;
37  len=length(tp_detailed_data);
38  if isfield(model,'t_part_id_in_basisgen')
39  %tp_detailed_data{model.t_part_id_in_basisgen} = [];
40  %tp_detailed_data{model.t_part_id_in_basisgen} = structcpy(tp_detailed_data{model.t_part_id_in_basisgen}, detailed_data);
41  if isfield(detailed_data,'RB')
42  tp_detailed_data{model.t_part_id_in_basisgen}.RB = detailed_data.RB;
43  tp_detailed_data{model.t_part_id_in_basisgen}.RB_info = detailed_data.RB_info;
44  end
45  tp_detailed_data{model.t_part_id_in_basisgen}.W = detailed_data.W;
46  tp_detailed_data{model.t_part_id_in_basisgen}.grid = detailed_data.grid;
47  else
48  %append actual basis as "new t_partition_detailed_data"
49  tp_detailed_data{len+1} = [];
50  %tp_detailed_data{len+1} = structcpy(tp_detailed_data{len+1}, detailed_data);
51  tp_detailed_data{len+1}.RB = detailed_data.RB;
52  tp_detailed_data{len+1}.RB_info = detailed_data.RB_info;
53  tp_detailed_data{len+1}.W = detailed_data.W;
54  tp_detailed_data{len+1}.grid = detailed_data.grid;
55  end
56  else
57  tp_detailed_data{1} = [];
58  tp_detailed_data{1} = structcpy(tp_detailed_data{1}, detailed_data);
59  end
60 
61 else
62  if ~isfield(detailed_data,'t_part_detailed_data')
63  error('No t-partition model. Can not create reduced_data');
64  else
65  tp_detailed_data = detailed_data.t_part_detailed_data;
66  end
67 
68 end
69 
70 
71 reduced_data = [];
72 
73 base_model = model.base_model;
74 
75 
76 nr_t_parts = length(tp_detailed_data);
77 
78 if (isfield(model,'t_part_for_simulation'))&&~isempty(model.t_part_for_simulation)
79  stop_part = model.t_part_for_simulation;
80 else
81  stop_part = nr_t_parts;
82 end
83 
84 
85 t_part_reduced_data = cell(1,stop_part);
86 if model.transition_model
87  if stop_part>1
88  t_part_transition_reduced_data = cell(1,stop_part-1);
89  end
90 end
91 
92 
93 %generate reduced_data for every partition without transition part
94 for t_part_indx = 1:stop_part
95 
96  %usual reduced_data
97  t_part_reduced_data{t_part_indx} = gen_reduced_data(base_model, tp_detailed_data{t_part_indx});
98 
99  %Transfer matrix
100  if t_part_indx>1
101  T=tp_detailed_data{t_part_indx}.RB' * detailed_data.W * tp_detailed_data{t_part_indx-1}.RB;
102  t_part_reduced_data{t_part_indx}.T = T;
103  end
104 
105  if t_part_indx>1 &&model.transition_model
106  %add the mixed explicit operator to reduced_data
107  t_part_transition_reduced_data{t_part_indx-1}=t_part_reduced_data{t_part_indx};
108  %decomp_old = model.decomp_mode;
109  model.decomp_mode =1;
110  [L_I, L_E, b] = model.operators_ptr(model, detailed_data);
111  for i=1:length(L_E)
112  t_part_transition_reduced_data{t_part_indx-1}.LL_E{i} = ...
113  tp_detailed_data{t_part_indx}.RB'*detailed_data.W* ...
114  L_E{i}*tp_detailed_data{t_part_indx-1}.RB;
115  end
116  %nr_comp = length(t_part_transition_reduced_data{t_part_indx-1}.LL_E);
117  % t_part_transition_reduced_data{t_part_indx-1}.LL_E{1}=T;
118 
119  %Fehlermatrizen?!?!?!?!?
120  end
121 
122 
123 end
124 
125 reduced_data.t_part_reduced_data = t_part_reduced_data;
126 if model.transition_model
127  reduced_data.t_part_transition_reduced_data = t_part_transition_reduced_data;
128 end
129 if model.t_part_in_basis_generation
130  reduced_data.N = t_part_reduced_data{stop_part}.N;
131 end
function s1 = structcpy(s1, s2)
copies the fields of structure s2 into structure s1. If the field to be copied does not exist in s1 y...
Definition: structcpy.m:17