1 classdef ReducedData < Greedy.User.IReducedDataNode & DataTree.CreatorDefault
2 % Reduced data implementation
for non-linear evolution problems with finite
3 % volume discretizations.
5 % See @ref DHO11 for details on the implementations of the reduced matrices
9 % reduced data of type TwoPhaseFlow.RbReducedDataNode depending on the
10 % reduced basis space only
14 % collateral reduced basis space only
18 % the collateral reduced basis space and the reduced basis space
23 properties(Transient, Access=
public)
36 properties(Dependent, SetAccess=private)
37 % number of reduced basis vectors stored in this data node.
40 % number of collateral reduced basis vectors stored in this data node.
43 % number of collateral reduced basis vectors used for error estimation.
50 % Constructor for the generation of the reduced matrices and vectors.
58 error('TwoPhaseFlow.
ReducedData constructor needs an argument');
62 copy_extract(rd, copy, rmodel);
64 fill_fields(rd, rmodel, detailed_data);
66 error('Did not find constructor for your arguments');
70 function conds = get_conds(this)
71 conds_rb = get_conds(this.rb_rd);
72 conds_ei = get_conds(this.ei_rd);
78 % overwrite DataTree.INode methods
80 function index = get_index(this,
id, mu, nt)
81 index = get_index(this.ei_rb_rd,
id, mu, nt);
84 function node = get(this, index)
88 node = get(this.ei_rb_rd, index);
94 function yesno = needs_subset_copy(this, rmodel)
95 % function yesno = needs_subset_copy(this, rmodel)
96 % @copybrief .Greedy.User.IReducedDataNode.needs_subset_copy()
98 % @copydetails .Greedy.User.IReducedDataNode.needs_subset_copy()
99 % This method always returns true, because it is only a container element
100 % with no data and can be copied very cheaply! A traversal over leafs in
101 % order to check whether referencing is possible, is too slow.
109 methods(Access=private)
111 function fill_fields(this, rmodel, detailed_data)
112 ei_dd = detailed_data.ei;
113 rb_dd = detailed_data.rb;
114 sat_ei_dd = get_by_description(ei_dd, 'L_saturation');
115 vel_ei_dd = get_by_description(ei_dd, 'L_velocity');
116 sat_rb_dd = get_by_description(rb_dd, 'saturation');
117 vel_rb_dd = get_by_description(rb_dd, 'velocity');
118 prs_rb_dd = get_by_description(rb_dd, 'pressure');
120 this.rmodel = rmodel;
122 sat_ei_rd = create_tree(sat_ei_dd, this, 'L_saturation', [], [], []);
123 if rmodel.descr.linear_velocity
124 this.ei_rd = Greedy.DataTree.Reduced.IdMapNode({
'L_saturation'});
125 set(this.ei_rd, 1, sat_ei_rd);
127 vel_ei_rd = create_tree(vel_ei_dd,
this,
'L_velocity', [], [], []);
128 this.ei_rd = Greedy.DataTree.Reduced.IdMapNode({
'L_saturation',
'L_velocity'});
129 set(this.ei_rd, 1, sat_ei_rd);
130 set(this.ei_rd, 2, vel_ei_rd);
134 sat_rb_rd = create_tree(sat_rb_dd,
this, [], [], [], []);
135 vel_rb_rd = create_tree(vel_rb_dd,
this, [], [], [], []);
136 prs_rb_rd = create_tree(prs_rb_dd,
this, [], [], [], []);
137 this.rb_rd = Greedy.DataTree.Reduced.IdMapNode({
'saturation',
'velocity',
'pressure'});
138 set(this.rb_rd, 1, sat_rb_rd);
139 set(this.rb_rd, 2, vel_rb_rd);
140 set(this.rb_rd, 3, prs_rb_rd);
142 this.mode =
'separable_function';
143 this.separable_op = rmodel.descr.init_values;
144 sat_init_rb_rd = create_tree(sat_rb_dd,
this, [], [], [], []);
146 this.detailed_rb_tree = rb_dd;
148 this.mode =
'separable_operator';
150 if rmodel.descr.linear_velocity
152 this.rb_idsearch = {
'velocity',
'pressure'};
153 this.separable_op = rmodel.descr.L_velocity;
154 L_vel_rb_rd = create_tree(vel_rb_dd,
this, [], [], [], []);
158 this.rb_idsearch = {
'velocity',
'pressure'};
159 this.separable_op = rmodel.descr.L_divergence;
160 L_div_rb_rd = create_tree(vel_rb_dd,
this, [], [], [], []);
162 this.rb_idsearch = {
'pressure'};
163 this.separable_op = rmodel.descr.L_pressure;
164 L_prs_rb_rd = create_tree(prs_rb_dd,
this, [], [], [], []);
165 this.separable_op = [];
170 this.detailed_ei_tree = sat_ei_dd;
171 this.reduced_ei_tree = sat_ei_rd;
172 this.mode =
'ei_rb_1';
173 this.rb_idsearch = {
'saturation',
'velocity'};
175 sat_ei_rb_rd = create_tree(sat_rb_dd,
this, [], [], [], []);
177 if ~rmodel.descr.linear_velocity
178 this.detailed_ei_tree = vel_ei_dd;
179 this.reduced_ei_tree = vel_ei_rd;
180 this.rb_idsearch = {
'saturation',
'velocity',
'pressure'};
182 vel_ei_rb_rd = create_tree(sat_rb_dd,
this, [], [], [], []);
184 this.detailed_ei_tree = [];
185 this.reduced_ei_tree = [];
186 this.detailed_rb_tree = [];
187 this.rb_idsearch = [];
192 this.ei_rb_rd = Greedy.DataTree.Reduced.IdMapNode({
'L_saturation',
'L_velocity',
'L_divergence',
'L_pressure_mean',
'sat_init'});
193 set(this.ei_rb_rd, 1, sat_ei_rb_rd);
194 if rmodel.descr.linear_velocity
195 set(this.ei_rb_rd, 2, L_vel_rb_rd);
197 set(this.ei_rb_rd, 2, vel_ei_rb_rd);
199 set(this.ei_rb_rd, 3, L_div_rb_rd);
200 set(this.ei_rb_rd, 4, L_prs_rb_rd);
201 set(this.ei_rb_rd, 5, sat_init_rb_rd);
205 function copy_extract(
this, copy, rmodel)
206 this.rmodel = rmodel;
208 this.ei_rd = create_tree(copy.ei_rd, this, [], [], [], []);
210 this.rb_rd = create_tree(copy.rb_rd, this, [], [], [], []);
211 this.mode = 'ce_ei_rb';
212 this.ei_rb_rd = create_tree(copy.ei_rb_rd, this, [], [], [], []);
220 function node = create_leaf_node(this, arg_node, basepath, mu_cube, tslice)
221 % function new_node = create_leaf_node(this, node, basepath, mu_cube, tslice)
222 % specialization method for
leaf elements as described in
223 % DataTree.ICreator.create_leaf_node().
225 % @copydetails .DataTree.ICreator.create_leaf_node()
227 % There are seven modes for the creation of new
leaf elements:
229 % Greedy.DataTree.Detailed.EILeafNode
231 % Greedy.DataTree.Detailed.RBLeafNode
232 % - 'ei_rb_2' creates a "mixed"
leaf node
234 % Greedy.DataTree.Detailed.RBLeafNode and a
235 % Greedy.DataTree.Detailed.EILeafNode
object.
236 % - 'ei_rb_1' At this stage, the "mixed"
leaf node tree should be of
237 % the same state as the pure reduced basis tree. If this differs
238 % from the collateral space, the "mixed" tree needs to be refined
239 % by attaching tree levels from the EI tree. This is initiated by
242 % extracts smaller reduced matrices and vectors.
244 % extracts smaller reduced matrices and vectors.
246 % (optionally) extracts smaller reduced matrices and vectors.
253 case 'separable_function'
254 node = Greedy.DataTree.Reduced.SeparableFunctionNode(this.rmodel, arg_node, this.separable_op);
255 case 'separable_operator'
256 this.detailed_rb_leaf{this.id_ind} = arg_node;
257 if this.id_ind < length(this.rb_idsearch)
258 this.id_ind = this.id_ind + 1;
259 rb_dd_temp = get_by_description(this.detailed_rb_tree, this.rb_idsearch{this.id_ind}, [], []);
260 node = create_tree(rb_dd_temp,
this, this.rb_idsearch{this.id_ind}, mu_cube, tslice, []);
261 this.id_ind = this.id_ind - 1;
263 this.detailed_rb_leaf{this.id_ind} = arg_node;
264 this.detailed_rb_leaf = Greedy.DataTree.Reduced.IdMapNode(this.rb_idsearch, this.detailed_rb_leaf);
265 node = Greedy.DataTree.Reduced.SeparableOperatorNode(this.rmodel, this.detailed_rb_leaf, this.separable_op);
266 this.detailed_rb_leaf = {};
269 this.detailed_rb_leaf{this.id_ind} = arg_node;
270 this.reduced_rb_leaf{this.id_ind} =
get(this.rb_rd, [this.id_ind, basepath]);
272 if this.id_ind < length(this.rb_idsearch)
273 this.id_ind = this.id_ind + 1;
274 rb_dd_temp = get_by_description(this.detailed_rb_tree, this.rb_idsearch{this.id_ind}, [], []);
275 node = create_tree(rb_dd_temp,
this, this.rb_idsearch{this.id_ind}, mu_cube, tslice, []);
276 this.id_ind = this.id_ind - 1;
278 this.mode =
'ei_rb_2';
280 node = create_tree(this.detailed_ei_tree,...
282 [], mu_cube, tslice,...
285 this.detailed_rb_leaf = {};
286 this.reduced_rb_leaf = {};
287 this.mode =
'ei_rb_1';
290 reduced_ei_leaf =
get(this.reduced_ei_tree, basepath);
291 detailed_ei_leaf = arg_node;
293 this.reduced_rb_leaf = Greedy.DataTree.Reduced.IdMapNode(this.rb_idsearch, this.reduced_rb_leaf);
294 this.detailed_rb_leaf = Greedy.DataTree.Reduced.IdMapNode(this.rb_idsearch, this.detailed_rb_leaf);
296 node = TwoPhaseFlow.EiRbReducedDataNode(this.rmodel, ...
297 this.reduced_rb_leaf, ...
298 this.detailed_rb_leaf, ...
302 if needs_subset_copy(arg_node, this.rmodel)
303 node = TwoPhaseFlow.EiReducedDataNode(this.rmodel, arg_node);
308 if needs_subset_copy(arg_node, this.rmodel)
309 node = TwoPhaseFlow.RbReducedDataNode(this.rmodel, arg_node);
314 if needs_subset_copy(arg_node, this.rmodel)
325 function N = get.N(this)
327 N = create_scalar_tree(this.rb_rd, @(x) x.N);
330 function M = get.M(this)
332 M = create_scalar_tree(this.ei_rd, @(x) x.M);
335 function Mstrich = get.Mstrich(this)
337 Mstrich = create_scalar_tree(this.ei_rd, @(x) x.Mstrich);