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 NonlinEvol.RbReducedDataNode depending on the
10  % reduced basis space only
11  rb_rd;
12 
13  % reduced data of type NonlinEvol.EiReducedDataNode depending on the
14  % collateral reduced basis space only
15  ei_rd;
16 
17  % reduced data of type NonlinEvol.EiRbReducedDataNode depending on both
18  % the collateral reduced basis space and the reduced basis space
19  ei_rb_rd;
20 
21  % this is not used at the moment
22  idsearch = [];
23  end
24 
25  properties(Transient, Access=private)
26  detailed_ei_tree;
27  detailed_rb_leaf;
28  reduced_rb_leaf;
29  mode;
30  rmodel;
31  end
32 
33  properties(Dependent, SetAccess=private)
34  % number of reduced basis vectors stored in this data node.
35  N;
36 
37  % number of collateral reduced basis vectors stored in this data node.
38  M;
39 
40  % number of collateral reduced basis vectors used for error estimation.
41  Mstrich;
42  end
43 
44 
45  methods
46  function rd = ReducedData(rmodel, detailed_data)
47  % Constructor for the generation of the reduced matrices and vectors.
48  %
49  % Parameters:
50  % rmodel: of type NonlinEvol.ReducedModel
51  % detailed_data: of type IDetailedData
52  %
53  %
54  if nargin == 0
55  error('NonlinEvol.ReducedData constructor needs an argument');
56  elseif nargin == 2 && isa(rmodel, 'IReducedModel') ...
57  && isa(detailed_data, 'NonlinEvol.ReducedData')
58  copy = detailed_data;
59  copy_extract(rd, copy, rmodel);
60  elseif nargin == 2 && isa(rmodel, 'IReducedModel') && isa(detailed_data, 'IDetailedData')
61  fill_fields(rd, rmodel, detailed_data);
62  else
63  error('Did not find constructor for your arguments');
64  end
65  end
66 
67  function conds = get_conds(this)
68  conds_rb = get_conds(this.rb_rd);
69  conds_ei = get_conds(this.ei_rd);
70  conds = structcpy(conds_rb, conds_ei);
71  end
72 
73  end
74 
75  methods(Static)
76 
77  %
78  %
79  % Parameters:
80  % detailed_data: of type ::GreedyDataTreeDetailed.RBLeafNode
81  [LL_I, bb_I] = rb_operators(rmodel, detailed_data, decomp_mode);
82 
83  end
84 
85  % overwrite DataTreeINode methods
86  methods
87  function index = get_index(this, id, mu, nt)
88  index = get_index(this.ei_rb_rd, id, mu, nt);
89  end
90 
91  function node = get(this, index)
92  node = get(this.ei_rb_rd, index);
93  end
94  end
95 
96  methods
97  function yesno = needs_subset_copy(this, rmodel)
98  % function yesno = needs_subset_copy(this, rmodel)
99  % @copybrief ::GreedyUser.IReducedDataNode.needs_subset_copy()
100  %
101  % @copydetails ::GreedyUser.IReducedDataNode.needs_subset_copy()
102  % This method always returns true, because it is only a container element
103  % with no data and can be copied very cheaply! A traversal over leafs in
104  % order to check whether referencing is possible, is too slow.
105  %
106  % Parameters:
107  % rmodel: of type NonlinEvolReducedModel
108  yesno = true;
109  end
110  end
111 
112  methods(Access=private)
113 
114  function fill_fields(this, rmodel, detailed_data)
115  this.rmodel = rmodel;
116  this.mode = 'ei';
117  this.ei_rd = create_tree(detailed_data.ei, this, [], [], [], []);
118  this.mode = 'rb';
119  this.rb_rd = create_tree(detailed_data.rb, this, [], [], [], []);
120  this.rmodel = [];
121 
122  this.detailed_ei_tree = detailed_data.ei;
123  this.mode = 'ei_rb_1';
124  this.ei_rb_rd = create_tree(detailed_data.rb, this, [], [], [], []);
125  this.detailed_ei_tree = [];
126  this.mode = [];
127  end
128 
129  function copy_extract(this, copy, rmodel)
130  this.rmodel = rmodel;
131  this.mode = 'ce_ei';
132  this.ei_rd = create_tree(copy.ei_rd, this, [], [], [], []);
133  this.mode = 'ce_rb';
134  this.rb_rd = create_tree(copy.rb_rd, this, [], [], [], []);
135  this.mode = 'ce_ei_rb';
136  this.ei_rb_rd = create_tree(copy.ei_rb_rd, this, [], [], [], []);
137  this.mode = [];
138  end
139 
140  end
141 
142  % ICreator methods
143  methods
144  function node = create_leaf_node(this, arg_node, basepath, mu_cube, tslice)
145  % function new_node = create_leaf_node(this, node, basepath, mu_cube, tslice)
146  % specialization method for leaf elements as described in
147  % DataTreeICreator.create_leaf_node().
148  %
149  % @copydetails ::DataTreeICreator.create_leaf_node()
150  %
151  % There are seven modes for the creation of new leaf elements:
152  % - 'ei' creates a new NonlinEvol.EiReducedDataNode out of a
153  % Greedy.DataTree.Detailed.EILeafNode
154  % - 'rb' creates a new NonlinEvol.RbReducedDataNode out of a
155  % Greedy.DataTree.Detailed.RBLeafNode
156  % - 'ei_rb_2' creates a "mixed" leaf node
158  % Greedy.DataTree.Detailed.RBLeafNode and a
159  % Greedy.DataTree.Detailed.EILeafNode object.
160  % - 'ei_rb_1' At this stage, the "mixed" leaf node tree should be of
161  % the same state as the pure reduced basis tree. If this differs
162  % from the collateral space, the "mixed" tree needs to be refined
163  % by attaching tree levels from the EI tree. This is initiated by
164  % this mode.
165  % - 'ce_ei' copies the NonlinEvol.EiReducedDataNode and (optionally)
166  % extracts smaller reduced matrices and vectors.
167  % - 'ce_rb' copies the NonlinEvol.RbReducedDataNode and (optionally)
168  % extracts smaller reduced matrices and vectors.
169  % - 'ce_ei_rb' copies the NonlinEvol.EiRbReducedDataNode and
170  % (optionally) extracts smaller reduced matrices and vectors.
171 
172  switch(this.mode)
173  case 'ei'
174  node = NonlinEvol.EiReducedDataNode(this.rmodel, arg_node);
175  case 'rb'
176  node = NonlinEvol.RbReducedDataNode(this.rmodel, arg_node);
177  case 'ei_rb_1'
178  this.detailed_rb_leaf = arg_node;
179  this.reduced_rb_leaf = get(this.rb_rd, basepath);
180  this.mode = 'ei_rb_2';
182  node = create_tree(this.detailed_ei_tree,...
183  this, ...
184  this.idsearch, mu_cube, tslice,...
185  []);
186 
187  this.detailed_rb_leaf = [];
188  this.reduced_rb_leaf = [];
189  this.mode = 'ei_rb_1';
190  case 'ei_rb_2'
191  reduced_ei_leaf = get(this.ei_rd, basepath);
192  detailed_ei_leaf = arg_node;
193 
194  node = NonlinEvol.EiRbReducedDataNode(this.reduced_rb_leaf, ...
195  this.detailed_rb_leaf, ...
196  reduced_ei_leaf, ...
197  detailed_ei_leaf);
198  case 'ce_ei'
199  if needs_subset_copy(arg_node, this.rmodel)
200  node = NonlinEvol.EiReducedDataNode(this.rmodel, arg_node);
201  else
202  node = arg_node;
203  end
204  case 'ce_rb'
205  if needs_subset_copy(arg_node, this.rmodel)
206  node = NonlinEvol.RbReducedDataNode(this.rmodel, arg_node);
207  else
208  node = arg_node;
209  end
210  case 'ce_ei_rb'
211  if needs_subset_copy(arg_node, this.rmodel)
212  node = NonlinEvol.EiRbReducedDataNode(this.rmodel, arg_node, this.rb_rd, this.ei_rd);
213  else
214  node = arg_node;
215  end
216  end
217  end
218  end
219 
220  methods
221  function N = get.N(this)
222 
223  N = create_scalar_tree(this.ei_rb_rd, @(x) x.N);
224  end
225 
226  function M = get.M(this)
227 
228  M = create_scalar_tree(this.ei_rb_rd, @(x) x.M);
229  end
230 
231  function Mstrich = get.Mstrich(this)
232 
233  Mstrich = create_scalar_tree(this.ei_rb_rd, @(x) x.Mstrich);
234  end
235 
236  end
237 
238 end
239 
reduced model for non-linear evolution problems as given by a NonlinEvol.DetailedModel.
Definition: ReducedModel.m:18
Implementation of a Greedy.User.IReducedDataNode storing reduced data depending on collateral reduc...
Interface for leaf nodes of the DataTree in Greedy.User.ReducedData objects.
Reduced basis implementation for non-linear evolution equations.
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
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
Reduced data implementation for non-linear evolution problems with finite volume discretizations.
Reduced data implementation for non-linear evolution problems with finite volume discretizations.
Definition: ReducedData.m:18
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1
Implementation of a Greedy.User.IReducedDataNode storing reduced data depending on reduced basis sp...
Interface class for the generation and storage of reduced basis spaces as described in Module (M2)...
Definition: IDetailedData.m:17