1 function [LL_I, LL_E, bb, K_II, K_IE, K_EE, m_I, m_E, m] = ...
2 lin_evol_rb_operators(model, detailed_data)
3 %
function [LL_I, LL_E, bb, K_II, K_IE, K_EE, m_I, m_E, m] = ...
4 % lin_evol_rb_operators(model, [detailed_data])
6 %
function computing the time-dependent reduced basis operators and
9 %Function supports affine decomposition, i.e. different operation modes
10 % guided by optional field decomp_mode in params. See also the
11 % contents.txt
for general explanation
13 % Required fields of model
14 % operators_algorithm: name of
function for computing the
15 % L_E,L_I,b-operators with arguments (grid, params)
16 % example fv_operators_implicit
19 % Optional fields of model:
20 % mu_names : names of fields to be regarded as parameters in vector mu
21 % decomp_mode: operation mode of the
function
22 % -0=
'complete' (
default): no parameter dependence or decomposition is
23 % performed. output is as described above.
24 % -1=
'components': For each output argument a cell array of output
25 % arguments is returned representing the q-th component
26 % independent of the parameters given in mu_names
27 % -2=
'coefficients': For each output argument a cell array of output
28 % arguments is returned representing the q-th coefficient
29 % dependent of the parameters given in mu_names
31 % In
'coefficients' mode the detailed data is empty.
33 % Bernard Haasdonk 23.7.2006
35 % determine affine_decomposition_mode as integer
36 decomp_mode = model.decomp_mode;
39 if decomp_mode == 0 % complete: simple projection on RB
41 %eval(
'u0 = ',params.init_value_algorithm,
'(grid,params)']);
42 [L_I, L_E, b] = model.operators_ptr(model,detailed_data);
44 % apply all
operator contributions to RB:
45 L_E_RB = L_E * detailed_data.RB;
46 L_I_RB = L_I * detailed_data.RB;
48 % fill output quantities
52 LL_I = detailed_data.RB
' * A * L_I_RB;
55 LL_E = detailed_data.RB' * A * L_E_RB;
58 bb = detailed_data.RB
' * A * b;
61 K_II = L_I_RB' * A * L_I_RB;
64 K_IE = L_I_RB
' * A * L_E_RB;
67 K_EE = L_E_RB' * A * L_E_RB;
70 m_I = L_I_RB
' * A * b;
73 m_E = L_E_RB' * A * b;
78 elseif decomp_mode == 1
80 %eval('u0 =
',params.init_value_algorithm,'(grid,params)
']);
81 [L_I, L_E, b] = model.operators_ptr(model, detailed_data);
87 Nmax = size(detailed_data.RB,2);
88 H = size(detailed_data.RB,1);
91 % init output quantities
96 m_I = cell(Q_L_I*Q_b,1);
97 m_I(:) = {zeros(Nmax,1)};
98 m_E = cell(Q_L_E*Q_b,1);
99 m_E(:) = {zeros(Nmax,1)};
101 bb(:) = {zeros(Nmax,1)};
103 K_II = cell(Q_L_I*Q_L_I,1);
104 K_II(:) = {zeros(Nmax,Nmax)};
105 K_IE = cell(Q_L_I*Q_L_E,1);
106 K_IE(:) = {zeros(Nmax,Nmax)};
107 K_EE = cell(Q_L_E*Q_L_E,1);
108 K_EE(:) = {zeros(Nmax,Nmax)};
109 LL_I = cell(Q_L_I,1);
110 LL_I(:) = {zeros(Nmax,Nmax)};
111 LL_E = cell(Q_L_E,1);
112 LL_E(:) = {zeros(Nmax,Nmax)};
114 % apply all operator contributions to RB:
115 L_E_RB = cell(Q_L_E,1);
116 L_E_RB(:) = {zeros(H,Nmax)};
117 L_I_RB = cell(Q_L_I,1);
118 L_I_RB(:) = {zeros(H,Nmax)};
120 L_E_RB{q}(:,:)= L_E{q} * detailed_data.RB;
123 L_I_RB{q}(:,:)= L_I{q} * detailed_data.RB;
126 % fill output quantities
129 LL_I{q} = detailed_data.RB' * A * L_I_RB{q};
134 LL_E{q} = detailed_data.RB
' * A * L_E_RB{q};
139 bb{q} = detailed_data.RB' * A * b{q};
145 K_II{ (q1-1)*Q_L_I + q2}(:,:) = ...
146 L_I_RB{q1}
' * A * L_I_RB{q2};
150 % K_IE : time sequence of matrices
151 % K_IE{1} = Gram matrix of L_I_RB{1} and L_E_RB{1}
152 % K_IE{2} = Gram matrix of L_I_RB{1} and L_E_RB{2}
153 % so L_E is "inner loop". This must fit to the sigma-ordering
156 K_IE{ (q1-1)*Q_L_E + q2} = ...
157 L_I_RB{q1}' * A * L_E_RB{q2};
164 K_EE{ (q1-1)*Q_L_E + q2} = ...
165 L_E_RB{q1}
' * A * L_E_RB{q2};
172 m_I{ (q1-1)*Q_b + q2} = ...
173 L_I_RB{q1}' * A * b{q2};
180 m_E{ (q1-1)*Q_b + q2} = ...
181 L_E_RB{q1}
' * A * b{q2};
188 m{ (q1-1)*Q_b + q2} = ...
193 else % decomp_mode== 2 -> coefficients
194 [L_I, L_E, b] = model.operators_ptr(model,[]);
196 Q_L_I = length(L_I(:));
197 Q_L_E = length(L_E(:));
200 % rb-
operator coefficients can simply be forwarded
205 % pairs: products of sigmas:
206 K_II = repmatrows(L_I(:), Q_L_I) .* repmat(L_I(:), Q_L_I, 1);
207 K_IE = repmatrows(L_I(:), Q_L_E) .* repmat(L_E(:), Q_L_I, 1);
208 K_EE = repmatrows(L_E(:), Q_L_E) .* repmat(L_E(:), Q_L_E, 1);
209 m_I = repmatrows(L_I(:), Q_b) .* repmat(b(:) , Q_L_I, 1);
210 m_E = repmatrows(L_E(:), Q_b) .* repmat(b(:) , Q_L_E, 1);
211 m = repmatrows(b(:) , Q_b) .* repmat(b(:) , Q_b , 1);