1 classdef ReducedData < Greedy.User.IReducedDataNode
2 % Reduced data implementation
for linear evolution problems with finite
3 % volume discretizations
5 % See @ref HO08a
for details on the implementation of the reduced matrices
10 % Dof vectors of projections `\left\{{ \cal P }_{\text{red}}[u_0^q]
11 % \right\}_{q=1}^{Q_{u_0}}`.
13 % @sa LinEvol.ReducedModel.rb_init_values()
for details.
16 % `Q_I` reduced matrix
for implicit
operator `{\cal L}_{h,I}`
18 % The matrix entries are:
19 % ``({ \bf L}_I^q)_{ij} = \int \varphi_i {\cal L}^q_{h,I}[\varphi_j]``
20 %
for `i,j=1,\ldots,N` and `q=1,\ldots,Q_I`.
23 % `Q_E`-sequence of reduced matrices for explicit operator `{\cal L}_{h,E}`
25 % The matrix entries are:
26 % ``({ \bf L}_E^q)_{ij} = \int \varphi_i {\cal L}^q_{h,E}[\varphi_j]``
27 %
for `i,j=1,\ldots,N` and `q=1,\ldots,Q_E`.
30 % `Q_b`-sequence of reduced vectors for constant contributions `b_h`
32 % The matrix entries are:
33 % ``({ \bf b})_{i} = \int \varphi_i b^q_h``
34 %
for `i=1,\ldots,N` and `q=1,\ldots,Q_b`.
37 % `Q_I \cdot Q_I`-sequence of gram matrices
39 % The matrix entries are:
40 % ``({ \bf K}_{II}^{q_1,q_2})_{ij} = \int {\cal L}^{q_1}_{h,I}[\varphi_i] {\cal L}^{q_2}_{h,I}[\varphi_j]``
41 %
for `i,j=1,\ldots,N` and `q_1,q_2=1,\ldots,Q_I`.
44 % `Q_I \cdot Q_E`-sequence of gram matrices
46 % The matrix entries are:
47 % ``({ \bf K}_{IE}^{q_1,q_2})_{ij} = \int {\cal L}^{q_1}_{h,I}[\varphi_i] {\cal L}^{q_2}_{h,E}[\varphi_j]``
48 %
for `i,j=1,\ldots,N` and `q_1=1,\ldots,Q_I, q_2=1,\ldots,Q_E`.
51 % `Q_E \cdot Q_E`-sequence of gram matrices
53 % The matrix entries are:
54 % ``({ \bf K}_{EE}^{q_1,q_2})_{ij} = \int {\cal L}^{q_1}_{h,E}[\varphi_i] {\cal L}^{q_2}_{h,E}[\varphi_j]``
55 %
for `i,j=1,\ldots,N` and `q_1,q_2=1,\ldots,Q_E`.
58 % `Q_I \cdot Q_b`-sequence of vectors
60 % The vector entries are:
61 % ``({ \bf m}_I^{q_1,q_2})_i = \int {\cal L}^{q_1}_{h,I}[\varphi_i] b_h^{q_2}``
62 %
for `i=1,\ldots,N` and `q_1=1,\ldots,Q_I, q_2=1,\ldots,Q_b`.
65 % `Q_E \cdot Q_b`-sequence of vectors
67 % The vector entries are:
68 % ``({ \bf m}_E^{q_1,q_2})_i = \int {\cal L}^{q_1}_{h,E}[\varphi_i] b_h^{q_2}``
69 %
for `i=1,\ldots,N` and `q_1=1,\ldots,Q_E, q_2=1,\ldots,Q_b`.
72 % `Q_b \cdot Q_b`-sequence of scalars
75 % ``{ \bf m}^{q_1,q_2} = \int b_h^{q_1} b_h^{q_2}``
76 % and `q_1,q_2=1,\ldots,Q_b`.
79 % in
case of output functional
this is a `Q_s`-sequence of vectors.
81 % The vector entries are:
82 % ``({ \bf s}^q)_i = s(\varphi_i)``
83 % for `i=1,\ldots,N` and `q_1=1,\ldots,Q_s`
86 % in
case of output functional
this is a `Q_s`-sequence of scalars.
89 % ``{ \bf s}_{l^2}^q = \|s(\varphi_1), \ldots, s(\varphi_N)\|_{l^2}``
90 %
for `q_1=1,\ldots,Q_s`
94 properties (SetAccess =
private, Dependent)
95 % number of reduced basis vectors stored in
this data node.
99 properties (SetAccess =
private)
100 % number of collateral reduced basis vectors stored in
this data node.
102 % number of collateral reduced basis vectors used
for error estimation
109 % Constructor
for the generation of the reduced matrices and vectors.
112 % rmodel: of type LinEvol.ReducedModel
117 error(
'LinEvol.ReducedData constructor needs an argument');
118 elseif nargin == 2 && isa(rmodel,
'IReducedModel') ...
119 && isa(detailed_data,
'LinEvol.ReducedData')
120 copy = detailed_data;
121 copy_extract(rd, copy, rmodel);
123 fill_fields(rd, rmodel, detailed_data);
125 error('Did not find constructor for your arguments');
129 function N = get.N(this)
131 N = size(this.a0{1},2);
137 function yesno = needs_subset_copy(
this, rmodel)
138 %
function yesno = needs_subset_copy(
this, rmodel)
139 % @copybrief .Greedy.User.IReducedDataNode.needs_subset_copy()
141 % @copydetails .Greedy.User.IReducedDataNode.needs_subset_copy()
144 % rmodel: of type LinEvol.ReducedModel
146 yesno = this.N ~= rmodel.N;
150 function conds = get_conds(
this)
151 disp('get_conds needs to be implemented for LinEvol.
ReducedData');
157 methods (Access=private)
158 function fill_fields(this, rmodel, detailed_data)
159 % function fill_fields(this, rmodel, detailed_data)
161 this.a0 = rmodel.descr.mexptr('rb_init_values', 1);
162 [this.LL_I, this.LL_E, this.bb, ...
163 this.K_II, this.K_IE, this.K_EE, ...
164 this.m_I, this.m_E, this.m ] ...
165 = LinEvolDune.ReducedData.rb_operators(rmodel, detailed_data, 1);
168 function copy_extract(this, copy, rmodel)
169 % function copy_extract(this, copy, rmodel)
173 % rmodel: reduced model of type LinEvol.
ReducedModel indicating the
174 % number of reduced basis vectors to be used in the
175 % 'reduced_data_subset'
177 % extract correct N-sized submatrices and subvectors from reduced_data
179 error('N too large for current size of reduced basis!');
183 this.a0 = subblock_sequence(copy.a0,1:N);
184 this.LL_I = subblock_sequence(copy.LL_I,1:N,1:N);
185 this.LL_E = subblock_sequence(copy.LL_E,1:N,1:N);
186 this.bb = subblock_sequence(copy.bb,1:N);
187 this.K_EE = subblock_sequence(copy.K_EE,1:N,1:N);
188 this.K_IE = subblock_sequence(copy.K_IE,1:N,1:N);
189 this.K_II = subblock_sequence(copy.K_II,1:N,1:N);
190 this.m_I = subblock_sequence(copy.m_I,1:N);
191 this.m_E = subblock_sequence(copy.m_E,1:N);
193 % if ~isempty(copy.T)
194 % this.T = copy.T(1:N,1:N);
197 model = rmodel.detailed_model;
198 if isfield(model,'name_output_functional')
199 this.s_RB = copy.s_RB(1:N);
200 this.s_l2norm = copy.s_l2norm;
211 % detailed_data : of type Greedy.DataTree.Detailed.RBLeafNode
212 function [LL_I, LL_E, bb, K_II, K_IE, K_EE, m_I, m_E, m] = rb_operators(rmodel, detailed_data, decomp_mode)
214 descr = rmodel.descr;
218 dLL_I = descr.coeff_ops.LL_I_ptr(mu);
219 dLL_E = descr.coeff_ops.LL_E_ptr(mu);
220 dbb = descr.coeff_ops.bb_ptr(mu);
221 % model.mexptr('set_mu', model.mu);
222 % foo = model.mexptr('rb_operators', decomp_mode);
227 % kron(dLL_I,dLL_E) == foo{6}
228 % kron(dLL_E,dbb) == foo{8}
229 % kron(dbb,dbb) == foo{9}
233 K_II = [1, dLL_I, dLL_I, kron(dLL_I,dLL_I) ];
234 K_EE = [1, dLL_E, dLL_E, kron(dLL_E,dLL_E) ];
235 K_IE = [1, dLL_I, dLL_E, kron(dLL_I,dLL_E) ];
236 m_I = [dbb, kron(dLL_I,dbb) ];
237 m_E = [dbb, kron(dLL_E,dbb) ];
240 foo = descr.mexptr(
'rb_operators', decomp_mode);
252 func2 = @(X) descr.dt * X;
253 func2t = @(X) descr.dt * X
';
254 func3 = @(X) descr.dt.^2 * X;
256 identity = speye(size(dLL_I{1}));
258 LL_I = [{identity}; ...
259 cellfun(func2 , dLL_I, 'UniformOutput
', false)];
261 LL_E = [{identity}; ...
262 cellfun(func2 , dLL_E, 'UniformOutput
', false)];
264 bb = cellfun(func2 , dbb , 'UniformOutput
', false);
266 K_II = [{identity}; ...
267 cellfun(func2t, dLL_I, 'UniformOutput
', false); ...
268 cellfun(func2 , dLL_I, 'UniformOutput
', false); ...
269 cellfun(func3 , dK_II, 'UniformOutput
', false)];
271 K_EE = [{identity}; ...
272 cellfun(func2t, dLL_E, 'UniformOutput
', false); ...
273 cellfun(func2 , dLL_E, 'UniformOutput
', false); ...
274 cellfun(func3 , dK_EE, 'UniformOutput
', false)];
276 K_IE = [{identity}; ...
277 cellfun(func2t, dLL_I, 'UniformOutput
', false); ...
278 cellfun(func2 , dLL_E, 'UniformOutput
', false); ...
279 cellfun(func3 , dK_IE, 'UniformOutput
', false)];
282 cellfun(func3 , dm_I , 'UniformOutput
', false)];
285 cellfun(func3 , dm_E , 'UniformOutput
', false)];
287 m = cellfun(func3 , dm , 'UniformOutput
', false);
289 else % decomp_mode == 0
290 assert(all(get_mu(rmodel) == get_mu(rmodel.detailed_model)));
291 LL_I = 1 + model.dt * dLL_I;
292 LL_E = 1 + model.dt * dLL_E;
294 K_II = 1 + model.dt * dLL_I' + model.dt * dLL_I + model.dt^2 * dK_II;
295 K_EE = 1 + model.dt * dLL_E' + model.dt * dLL_E + model.dt^2 * dK_EE;
296 K_IE = 1 + model.dt * dLL_I' + model.dt * dLL_E + model.dt^2 * dK_IE;
297 m_I = model.dt * dbb + model.dt^2 * dm_I;
298 m_E = model.dt * dbb + model.dt^2 * dm_E;