rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
rb_operators.m
1 function [LL_I, LL_E, bb, K_II, K_IE, K_EE, m_I, m_E, m] = rb_operators(rmodel, detailed_data, decomp_mode)
2 %function [LL_I, LL_E, bb, K_II, K_IE, K_EE, m_I, m_E, m] = rb_operators(rmodel, [detailed_data], decomp_mode)
3 % function computing the time-dependent reduced basis operators and vectors.
4 %
5 % Parameters:
6 % rmodel : of type LinEvol.ReducedModel
7 % detailed_data : of type Greedy.DataTree.Detailed.RBLeafNode
8 %
9 % Return values:
10 % LL_I : @copybrief LL_I
11 % LL_E : @copybrief LL_E
12 % bb : @copybrief bb
13 % K_II : @copybrief K_II
14 % K_IE : @copybrief K_IE
15 % K_EE : @copybrief K_EE
16 % m_I : @copybrief m_I
17 % m_E : @copybrief m_E
18 % m : @copybrief m
19 %
20 % In 'coefficients' mode the detailed data is empty.
21 
22 % Bernard Haasdonk 23.7.2006
23 
24 % determine affine_decomposition_mode as integer
25 model = rmodel.descr;
26 model.decomp_mode = decomp_mode;
27 
28 if decomp_mode == 2
29  [L_I, L_E, b] = model.operators_ptr(model,[]);
30 
31  Q_L_I = length(L_I(:));
32  Q_L_E = length(L_E(:));
33  Q_b = length(b(:));
34 
35  % rb-operator coefficients can simply be forwarded
36  LL_E = L_E;
37  LL_I = L_I;
38  bb = b;
39 
40  % pairs: products of sigmas:
41  K_II = repmatrows(L_I(:), Q_L_I) .* repmat(L_I(:), Q_L_I, 1);
42  K_IE = repmatrows(L_I(:), Q_L_E) .* repmat(L_E(:), Q_L_I, 1);
43  K_EE = repmatrows(L_E(:), Q_L_E) .* repmat(L_E(:), Q_L_E, 1);
44  m_I = repmatrows(L_I(:), Q_b) .* repmat(b(:) , Q_L_I, 1);
45  m_E = repmatrows(L_E(:), Q_b) .* repmat(b(:) , Q_L_E, 1);
46  m = repmatrows(b(:) , Q_b) .* repmat(b(:) , Q_b , 1);
47 
48 else
49 
50  if isa(detailed_data, 'IDetailedData')
51  model_data = detailed_data.model_data;
52  else
53  model_data = detailed_data;
54  end
55 
56  if decomp_mode == 0 % complete: simple projection on RB
57 
58  %eval('u0 = ',params.init_value_algorithm,'(grid,params)']);
59  [L_I, L_E, b] = model.operators_ptr(model,model_data);
60 
61  % apply all operator contributions to RB:
62  L_E_RB = L_E * detailed_data.RB;
63  L_I_RB = L_I * detailed_data.RB;
64 
65  % fill output quantities
66  % LL_I : matrix
67  A = model_data.W;
68 
69  LL_I = detailed_data.RB' * A * L_I_RB;
70 
71  % LL_E : matrix
72  LL_E = detailed_data.RB' * A * L_E_RB;
73 
74  % bb : vector
75  bb = detailed_data.RB' * A * b;
76 
77  % K_II : matrix
78  K_II = L_I_RB' * A * L_I_RB;
79 
80  % K_IE : matrix
81  K_IE = L_I_RB' * A * L_E_RB;
82 
83  % K_EE : matrice
84  K_EE = L_E_RB' * A * L_E_RB;
85 
86  % m_I : vector
87  m_I = L_I_RB' * A * b;
88 
89  % m_E : vector
90  m_E = L_E_RB' * A * b;
91 
92  % m : scalar
93  m = b' * A * b;
94 
95  elseif decomp_mode == 1
96 
97  %eval('u0 = ',params.init_value_algorithm,'(grid,params)']);
98  [L_I, L_E, b] = model.operators_ptr(model, model_data);
99 
100  Q_L_I = size(L_I,1);
101  Q_L_E = size(L_E,1);
102  Q_b = length(b);
103 
104  Nmax = size(detailed_data.RB,2);
105  H = size(detailed_data.RB,1);
106  A = model_data.W;
107 
108  % init output quantities
109  % scalars:
110  m = cell(Q_b*Q_b,1);
111  m(:) = {zeros(1,1)};
112  % vectors:
113  m_I = cell(Q_L_I*Q_b,1);
114  m_I(:) = {zeros(Nmax,1)};
115  m_E = cell(Q_L_E*Q_b,1);
116  m_E(:) = {zeros(Nmax,1)};
117  bb = cell(Q_b,1);
118  bb(:) = {zeros(Nmax,1)};
119  % matrices:
120  K_II = cell(Q_L_I*Q_L_I,1);
121  K_II(:) = {zeros(Nmax,Nmax)};
122  K_IE = cell(Q_L_I*Q_L_E,1);
123  K_IE(:) = {zeros(Nmax,Nmax)};
124  K_EE = cell(Q_L_E*Q_L_E,1);
125  K_EE(:) = {zeros(Nmax,Nmax)};
126  LL_I = cell(Q_L_I,1);
127  LL_I(:) = {zeros(Nmax,Nmax)};
128  LL_E = cell(Q_L_E,1);
129  LL_E(:) = {zeros(Nmax,Nmax)};
130 
131  % apply all operator contributions to RB:
132  L_E_RB = cell(Q_L_E,1);
133  L_E_RB(:) = {zeros(H,Nmax)};
134  L_I_RB = cell(Q_L_I,1);
135  L_I_RB(:) = {zeros(H,Nmax)};
136  for q=1:Q_L_E
137  L_E_RB{q}(:,:)= L_E{q} * detailed_data.RB;
138  end;
139  for q=1:Q_L_I
140  L_I_RB{q}(:,:)= L_I{q} * detailed_data.RB;
141  end;
142 
143  % fill output quantities
144  % LL_I : matrices
145  for q = 1:Q_L_I;
146  LL_I{q} = detailed_data.RB' * A * L_I_RB{q};
147  end;
148 
149  % LL_E : matrices
150  for q = 1:Q_L_E;
151  LL_E{q} = detailed_data.RB' * A * L_E_RB{q};
152  end;
153 
154  % bb : vectors
155  for q = 1:Q_b;
156  bb{q} = detailed_data.RB' * A * b{q};
157  end;
158 
159  % K_II : matrices
160  for q1 = 1:Q_L_I;
161  for q2 = 1:Q_L_I;
162  K_II{ (q1-1)*Q_L_I + q2}(:,:) = ...
163  L_I_RB{q1}' * A * L_I_RB{q2};
164  end;
165  end;
166 
167  % K_IE : time sequence of matrices
168  % K_IE{1} = Gram matrix of L_I_RB{1} and L_E_RB{1}
169  % K_IE{2} = Gram matrix of L_I_RB{1} and L_E_RB{2}
170  % so L_E is "inner loop". This must fit to the sigma-ordering
171  for q1 = 1:Q_L_I;
172  for q2 = 1:Q_L_E;
173  K_IE{ (q1-1)*Q_L_E + q2} = ...
174  L_I_RB{q1}' * A * L_E_RB{q2};
175  end;
176  end;
177 
178  % K_EE : matrices
179  for q1 = 1:Q_L_E;
180  for q2 = 1:Q_L_E;
181  K_EE{ (q1-1)*Q_L_E + q2} = ...
182  L_E_RB{q1}' * A * L_E_RB{q2};
183  end;
184  end;
185 
186  % m_I : vectors
187  for q1 = 1:Q_L_I;
188  for q2 = 1:Q_b;
189  m_I{ (q1-1)*Q_b + q2} = ...
190  L_I_RB{q1}' * A * b{q2};
191  end;
192  end;
193 
194  % m_E : vectors
195  for q1 = 1:Q_L_E;
196  for q2 = 1:Q_b;
197  m_E{ (q1-1)*Q_b + q2} = ...
198  L_E_RB{q1}' * A * b{q2};
199  end;
200  end;
201 
202  % m : scalars
203  for q1 = 1:Q_b;
204  for q2 = 1:Q_b;
205  m{ (q1-1)*Q_b + q2} = ...
206  b{q1}' * A * b{q2};
207  end
208  end
209  end
210 end
211 
212 end
213 
reduced model for linear evolution problems as given by a LinEvol.DetailedModel.
Definition: ReducedModel.m:18
DataTree implementation for generated detailed and reduced data
Definition: DuneRBLeafNode.m:2
tree node implementation for a detailed data structure holding a reduced basis
Definition: RBLeafNode.m:20
Reduced basis implementation for linear evolution equations.
DataTree specialization for detailed data generated by a Greedy algorithm instance.
Definition: DuneRBLeafNode.m:3
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1