rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ReducedData.m
1 classdef ReducedData < Greedy.User.IReducedDataNode & DataTree.CreatorDefault
2  % Reduced data implementation for non-linear evolution problems with finite
3  % volume discretizations.
4  %
5  % See @ref DHO11 for details on the implementations of the reduced matrices
6  % and vectors.
7 
8  properties
9  % reduced data of type TwoPhaseFlow.RbReducedDataNode depending on the
10  % reduced basis space only
11  rb_rd;
12 
13  % reduced data of type TwoPhaseFlow.EiReducedDataNode depending on the
14  % collateral reduced basis space only
15  ei_rd;
16 
17  % reduced data of type TwoPhaseFlow.EiRbReducedDataNode depending on both
18  % the collateral reduced basis space and the reduced basis space
19  ei_rb_rd;
20 
21  end
22 
23  properties(Transient, Access=public)
24  detailed_ei_tree;
25  reduced_ei_tree;
26  detailed_rb_tree;
27  detailed_rb_leaf;
28  reduced_rb_leaf;
29  rb_idsearch;
30  separable_op;
31  id_ind;
32  mode;
33  rmodel;
34  end
35 
36  properties(Dependent, SetAccess=private)
37  % number of reduced basis vectors stored in this data node.
38  N;
39 
40  % number of collateral reduced basis vectors stored in this data node.
41  M;
42 
43  % number of collateral reduced basis vectors used for error estimation.
44  Mstrich;
45  end
46 
47 
48  methods
49  function rd = ReducedData(rmodel, detailed_data)
50  % Constructor for the generation of the reduced matrices and vectors.
51  %
52  % Parameters:
53  % rmodel: of type TwoPhaseFlow.ReducedModel
54  % detailed_data: of type IDetailedData
55  %
56  %
57  if nargin == 0
58  error('TwoPhaseFlow.ReducedData constructor needs an argument');
59  elseif nargin == 2 && isa(rmodel, 'IReducedModel') ...
60  && isa(detailed_data, 'TwoPhaseFlow.ReducedData')
61  copy = detailed_data;
62  copy_extract(rd, copy, rmodel);
63  elseif nargin == 2 && isa(rmodel, 'IReducedModel') && isa(detailed_data, 'IDetailedData')
64  fill_fields(rd, rmodel, detailed_data);
65  else
66  error('Did not find constructor for your arguments');
67  end
68  end
69 
70  function conds = get_conds(this)
71  conds_rb = get_conds(this.rb_rd);
72  conds_ei = get_conds(this.ei_rd);
73  conds = structcpy(conds_rb, conds_ei);
74  end
75 
76  end
77 
78  % overwrite DataTreeINode methods
79  methods
80  function index = get_index(this, id, mu, nt)
81  index = get_index(this.ei_rb_rd, id, mu, nt);
82  end
83 
84  function node = get(this, index)
85  if isempty(index)
86  node = this.ei_rb_rd;
87  else
88  node = get(this.ei_rb_rd, index);
89  end
90  end
91  end
92 
93  methods
94  function yesno = needs_subset_copy(this, rmodel)
95  % function yesno = needs_subset_copy(this, rmodel)
96  % @copybrief ::GreedyUser.IReducedDataNode.needs_subset_copy()
97  %
98  % @copydetails ::GreedyUser.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.
102  %
103  % Parameters:
104  % rmodel: of type TwoPhaseFlowReducedModel
105  yesno = true;
106  end
107  end
108 
109  methods(Access=private)
110 
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');
119 
120  this.rmodel = rmodel;
121  this.mode = 'ei';
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);
126  else
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);
131  end
132 
133  this.mode = 'rb';
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);
141 
142  this.mode = 'separable_function';
143  this.separable_op = rmodel.descr.init_values;
144  sat_init_rb_rd = create_tree(sat_rb_dd, this, [], [], [], []);
145 
146  this.detailed_rb_tree = rb_dd;
147 
148  this.mode = 'separable_operator';
149 
150  if rmodel.descr.linear_velocity
151  this.id_ind = 1;
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, [], [], [], []);
155  end
156 
157  this.id_ind = 1;
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, [], [], [], []);
161  this.id_ind = 1;
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 = [];
166 
167 
168 
169 
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'};
174  this.id_ind = 1;
175  sat_ei_rb_rd = create_tree(sat_rb_dd, this, [], [], [], []);
176 
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'};
181  this.id_ind = 1;
182  vel_ei_rb_rd = create_tree(sat_rb_dd, this, [], [], [], []);
183  end
184  this.detailed_ei_tree = [];
185  this.reduced_ei_tree = [];
186  this.detailed_rb_tree = [];
187  this.rb_idsearch = [];
188  this.id_ind = [];
189  this.mode = [];
190  this.rmodel = [];
191 
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);
196  else
197  set(this.ei_rb_rd, 2, vel_ei_rb_rd);
198  end
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);
202 
203  end
204 
205  function copy_extract(this, copy, rmodel)
206  this.rmodel = rmodel;
207  this.mode = 'ce_ei';
208  this.ei_rd = create_tree(copy.ei_rd, this, [], [], [], []);
209  this.mode = 'ce_rb';
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, [], [], [], []);
213  this.mode = [];
214  end
215 
216  end
217 
218  % ICreator methods
219  methods
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  % DataTreeICreator.create_leaf_node().
224  %
225  % @copydetails ::DataTreeICreator.create_leaf_node()
226  %
227  % There are seven modes for the creation of new leaf elements:
228  % - 'ei' creates a new TwoPhaseFlow.EiReducedDataNode out of a
229  % Greedy.DataTree.Detailed.EILeafNode
230  % - 'rb' creates a new TwoPhaseFlow.RbReducedDataNode out of a
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
240  % this mode.
241  % - 'ce_ei' copies the TwoPhaseFlow.EiReducedDataNode and (optionally)
242  % extracts smaller reduced matrices and vectors.
243  % - 'ce_rb' copies the TwoPhaseFlow.RbReducedDataNode and (optionally)
244  % extracts smaller reduced matrices and vectors.
245  % - 'ce_ei_rb' copies the TwoPhaseFlow.EiRbReducedDataNode and
246  % (optionally) extracts smaller reduced matrices and vectors.
247 
248  switch(this.mode)
249  case 'ei'
250  node = TwoPhaseFlow.EiReducedDataNode(this.rmodel, arg_node);
251  case 'rb'
252  node = TwoPhaseFlow.RbReducedDataNode(this.rmodel, arg_node);
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;
262  else
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 = {};
267  end
268  case 'ei_rb_1'
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]);
271 
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;
277  else
278  this.mode = 'ei_rb_2';
279 
280  node = create_tree(this.detailed_ei_tree,...
281  this, ...
282  [], mu_cube, tslice,...
283  []);
284 
285  this.detailed_rb_leaf = {};
286  this.reduced_rb_leaf = {};
287  this.mode = 'ei_rb_1';
288  end
289  case 'ei_rb_2'
290  reduced_ei_leaf = get(this.reduced_ei_tree, basepath);
291  detailed_ei_leaf = arg_node;
292 
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);
295 
296  node = TwoPhaseFlow.EiRbReducedDataNode(this.rmodel, ...
297  this.reduced_rb_leaf, ...
298  this.detailed_rb_leaf, ...
299  reduced_ei_leaf, ...
300  detailed_ei_leaf);
301  case 'ce_ei'
302  if needs_subset_copy(arg_node, this.rmodel)
303  node = TwoPhaseFlow.EiReducedDataNode(this.rmodel, arg_node);
304  else
305  node = arg_node;
306  end
307  case 'ce_rb'
308  if needs_subset_copy(arg_node, this.rmodel)
309  node = TwoPhaseFlow.RbReducedDataNode(this.rmodel, arg_node);
310  else
311  node = arg_node;
312  end
313  case 'ce_ei_rb'
314  if needs_subset_copy(arg_node, this.rmodel)
315  this.mode = 'ce_ei';
316  node = TwoPhaseFlow.EiRbReducedDataNode(this.rmodel, arg_node2);
317  else
318  node = arg_node;
319  end
320  end
321  end
322  end
323 
324  methods
325  function N = get.N(this)
326 
327  N = create_scalar_tree(this.rb_rd, @(x) x.N);
328  end
329 
330  function M = get.M(this)
331 
332  M = create_scalar_tree(this.ei_rd, @(x) x.M);
333  end
334 
335  function Mstrich = get.Mstrich(this)
336 
337  Mstrich = create_scalar_tree(this.ei_rd, @(x) x.Mstrich);
338  end
339 
340  end
341 
342 end
343 
Reduced data implementation for non-linear evolution problems with finite volume discretizations.
Definition: ReducedData.m:18
reduced model for non-linear evolution problems as given by a TwoPhaseFlow.DetailedModel.
Definition: ReducedModel.m:18
DataTree implementation for generated detailed and reduced data
Definition: DuneRBLeafNode.m:2
Interface for leaf nodes of the DataTree in Greedy.User.ReducedData objects.
Implementation of a Greedy.User.IReducedDataNode storing reduced data depending on collateral reduc...
Implementation of a Greedy.User.IReducedDataNode storing reduced data depending on reduced basis sp...
descr
The description structure holding information about the analytical parametrized problem and its discr...
Definition: IReducedModel.m:58
Reduced data implementation for non-linear evolution problems with finite volume discretizations.
Definition: leaf.m:17
default implementation of the DataTree.ICreator interface
Interface classes to be implemented by the Greedy.Algorithm user.
This is the interface for a reduced model providing methods to compute low dimensional reduced simula...
Definition: IReducedModel.m:17
DataTree specialization for reduced data constructed out of Greedy.DataTree.Detailed instances...
Definition: IdMapNode.m:3
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
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1
Interface class for the generation and storage of reduced basis spaces as described in Module (M2)...
Definition: IDetailedData.m:17