rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
EiRbReducedDataNode.m
1 classdef EiRbReducedDataNode < Greedy.User.IReducedDataNode
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(Dependent, SetAccess=private)
9  % empirical interpolation matrix `{\bf B}`
10  %
11  % The matrix entries are:
12  % ``({\bf B})_{ij} = q_i(x_j)``
13  % for `1 \leq i \leq j \leq N` and vanish elsewhere.
14  BM;
15 
16  % local grid of type .gridbase with added neighbours such that a sparse
17  % evaluation of the empirically interpolated operators in the interpolation
18  % points is possible on this grid.
19  grid_local_ext;
20 
21  % synonym for #grid_local_ext of type .gridbase
22  grid;
23 
24  % indices of grid entities in the #grid_local_ext structure where the
25  % interpolation points are situated.
26  TM_local;
27 
28  % indices of grid entities in the the global grid structure where the
29  % interpolation points are situated.
30  TM_global;
31 
32  gEI;
33 
34  gn_edges;
35 
36  gn_inner_edges;
37 
38  gn_boundary_edges;
39 
40  % empirical interpolation mass matrix.
41  %
42  % The matrix entries are:
43  % ``({ \bf M })_{ij} = \int q_i q_j``
44  % for `i,j=1,\ldots,M`
45  Mmass;
46 
47  end
48 
49  properties(Dependent, SetAccess=private)
50  % number of reduced basis vectors stored in this data node.
51  N;
52 
53  % number of collateral reduced basis vectors stored in this data node.
54  M;
55 
56  % number of collateral reduced basis vectors used for error estimation.
57  Mstrich;
58  end
59 
60  properties
61  % handle of object of type TwoPhaseFlow.RbReducedDataNode storing all reduced
62  % magnitudes based only on the reduced basis.
63  rb_rd;
64 
65  % handle of object of type TwoPhaseFlow.EiReducedDataNode storing all reduced
66  % magnitudes based only on the collateral reduced basis.
67  ei_rd;
68 
69  opdata;
70 
71  % "transition" mass matrix
72  %
73  % The matrix entries are:
74  % ``({ \bf D })_{ij} = \int q_i \varphi_j``
75  % for `i=1,\ldots,M, j=1,\ldots,N`
76  DE;
77 
78  % empirical interpolation matrix for operator with projection to reduced
79  % basis space with `M+M'` basis vectors.
80  %
81  % This matrix is the solution `{\bf C}`of the equation system
82  % ``{ \bf B C } = { \bf D }``
83  % with @ref #BM "empirical interpolation matrix" `{ \bf B }` and @ref #DE
84  % "transition matrix" `{\bf D}`.
85  %
86  % In case you have a vector of interpolation evaluations `\bf l` at
87  % interpolation points, the interpolation can the be calculated as
88  % ``{\bf C l}``.
89  CE;
90 
91  % empirical interpolation matrix for operator with projection to reduced
92  % basis space for the empirical interpolation with only `M` basis vectors.
93  %
94  % See also: #CE
95  CE_red;
96 
97  % restriction of the reduced basis vectors to interpolation DOFs of the
98  % local grid #grid_local_ext.
99  RB_local_ext;
100  end
102  methods
103  function rd = EiRbReducedDataNode(rmodel, ...
104  rb_reduced_data, rb_detailed_data, ...
105  ei_reduced_data, ei_detailed_data)
106  % Constructor for the generation of the reduced matrices and vectors.
107  %
108  % Parameters:
109  % rb_reduced_data: pure reduced basis reduced data structure of type TwoPhaseFlow.RbReducedDataNode
110  % rb_detailed_data: detailed data structure of type Greedy.DataTree.Detailed.RbLeafNode
111  % storing the reduced basis.
112  % ei_reduced_data: pure EI reduced data structure of type TwoPhaseFlow.EiReducedDataNode
113  % ei_detailed_data: detailed data structure of type Greedy.DataTree.Detailed.EiLeafNode
114  % storing the collateral reduced basis.
115  if nargin == 0
116  error('TwoPhaseFlow.EiRbReducedDataNode constructor needs an argument');
117  elseif nargin == 2 && isa(rmodel, 'IReducedModel') ...
118  && isa(rb_reduced_data, 'TwoPhaseFlow.EiRbReducedDataNode')
119  copy = rb_reduced_data;
120  copy_extract(rd, copy, rmodel);
121  elseif nargin == 5
122  fill_fields(rd, rmodel, rb_reduced_data, rb_detailed_data, ei_reduced_data, ei_detailed_data);
123  else
124  error('Did not find constructor for your arguments');
125  end
126  end
127 
128  function conds = get_conds(this)
129  conds_rb = create_tree(this.rb_rd, ...
130  DataTree.ScalarCreator(@(X) get_conds(X)),...
131  [], [], []);
132  conds_ei = get_conds(this.ei_rd);
133  if ~isempty(this.CE)
134  conds.CE = condest(this.CE);
135  end
136  if ~isempty(this.CE_red)
137  conds.CE_red = condest(this.CE_red);
138  end
139  conds = structcpy(conds_rb, conds_ei);
140  end
141 
142  end
143 
144  methods(Access=private)
145 
146  function fill_fields(this, rmodel, rb_red, rb_det, ei_red, ei_det)
147  this.rb_rd = rb_red;
148  this.ei_rd = ei_red;
149 
150  ret_vars = ei_det.ophandle.ret_vars;
151  MM = get_by_description(rmodel.M, ei_det.ophandle.id);
152  A = ei_det.ophandle.inner_product_matrix(ei_det.model_data);
153 
154  RB = cell(1, length(ret_vars));
155  for i = 1:length(ret_vars)
156  rb_det_i = get_by_description(rb_det, ret_vars{i});
157  N_i = get_by_description(rmodel.N, ret_vars{i});
158  RB{i} = rb_det_i.RB(:,1:N_i);
159  end
160  RB = cat(1,RB{:});
161  this.DE = RB' * A * ei_det.QM(:,1:MM);
162 
163  arg_vars = ei_det.ophandle.arg_vars;
164  arg_vars_short = ei_det.ophandle.arg_vars_short;
165 
166  this.RB_local_ext = [];
167  for i = 1:length(arg_vars);
168  rb_det_i = get_by_description(rb_det, arg_vars{i});
169  TM_global_i = this.ei_rd.TM_global_args{i};
170  avs = arg_vars_short{i};
171  N_i = get_by_description(rmodel.N, arg_vars{i});
172  this.RB_local_ext.(avs) = rb_det_i.RB(TM_global_i, 1:N_i);
173  end
174 
175  this.opdata = ei_det.ophandle.fill_opdata(rmodel, ei_det);
176  end
177 
178  function copy_extract(this, copy, rmodel)
179  MM = get_by_description(rmodel.M, copy.ei_rd.ophandle.id);
180  ophandle = copy.ei_rd.ophandle;
181  arg_vars = ophandle.arg_vars;
182  arg_vars_short = ophandle.arg_vars_short;
183  ret_var = ophandle.ret_vars;
184  N_ret = get_by_description(rmodel.N, ret_var{1});
185 
186  this.ei_rd = copy.ei_rd;
187  this.rb_rd = copy.rb_rd;
188  this.DE = copy.DE(1:N_ret, 1:MM);
189  for i = 1:length(arg_vars_short)
190  av = arg_vars{i};
191  avs = arg_vars_short{i};
192  N_arg = get_by_description(rmodel.N, av);
193  if MM == copy.M
194  this.RB_local_ext.(avs) = copy.RB_local_ext.(avs)(:, 1:N_arg);
195  else
196  if ~isempty(this.ei_rd.TM_reduction_args)
197  TM_reduction_i = this.ei_rd.TM_reduction_args{i};
198  this.RB_local_ext.(avs) = copy.RB_local_ext(TM_reduction_i, 1:N_arg);
199  else
200  error('the empirical interpolation points are _not_ cropped!');
201  end
202  end
203  end
204  this.opdata = ophandle.copy_extract_opdata(copy.opdata, rmodel, this.ei_rd.ophandle.id);
205  end
206  end
207 
208  methods
209 
210  function N = get.N(this)
211  N = create_tree(this.rb_rd, ...
212  DataTree.ScalarCreator(@(X) X.N), ...
213  [], [], []);
214  end
215 
216  function M = get.M(this)
217  M = this.ei_rd.M;
218  end
219 
220  function Mstrich = get.Mstrich(this)
221  Mstrich = this.ei_rd.Mstrich;
222  end
223 
224  function BM = get.BM(this)
225  BM = this.ei_rd.BM;
226  end
227 
228  function Mmass = get.Mmass(this)
229  Mmass = this.ei_rd.Mmass;
230  end
231 
232  function grid_local_ext = get.grid_local_ext(this)
233  grid_local_ext = this.ei_rd.grid_local_ext;
234  end
235 
236  function grid_local_ext = get.grid(this)
237  grid_local_ext = this.ei_rd.grid_local_ext;
238  end
239 
240  function TM_global = get.TM_global(this)
241  TM_global = this.ei_rd.TM_global;
242  end
244  function gEI = get.gEI(this)
245  gEI = this.ei_rd.gEI;
246  end
247 
248  function gn_edges = get.gn_edges(this)
249  gn_edges = this.ei_rd.gn_edges;
250  end
251 
252  function gn_inner_edges = get.gn_inner_edges(this)
253  gn_inner_edges = this.ei_rd.gn_inner_edges;
254  end
255 
256  function gn_boundary_edges = get.gn_boundary_edges(this)
257  gn_boundary_edges = this.ei_rd.gn_boundary_edges;
258  end
259 
260  function TM_local = get.TM_local(this)
261  TM_local = this.ei_rd.TM_local;
262  end
263 
264  function yesno = needs_subset_copy(this, rmodel)
265  % function yesno = needs_subset_copy(this, rmodel)
266  % @copybrief .Greedy.User.IReducedDataNode.needs_subset_copy()
267  %
268  % @copydetails .Greedy.User.IReducedDataNode.needs_subset_copy()
269  %
270  % Parameters:
271  % rmodel: of type TwoPhaseFlow.ReducedModel
272 
273  yesno = needs_subset_copy(this.rb_rd, rmodel) || needs_subset_copy(this.ei_rd, rmodel);
274  end
275 
276 
277  end
278 end
279 
grid_local_ext
local grid with added neighbours such that a sparse evaluation of the empirically interpolated operat...
reduced model for non-linear evolution problems as given by a TwoPhaseFlow.DetailedModel.
Definition: ReducedModel.m:18
TM_global
indices of grid entities in the the global grid structure where the interpolation points are situated...
TM_local
indices of grid entities in the grid_local_ext structure where the interpolation points are situated...
BM
empirical interpolation matrix
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...
Mstrich
number of collateral reduced basis vectors used for error estimation.
Implementation of a Greedy.User.IReducedDataNode storing reduced data depending on reduced basis sp...
Reduced data implementation for non-linear evolution problems with finite volume discretizations.
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
Mmass
empirical interpolation mass matrix.
M
number of collateral reduced basis vectors stored in this data node.
Simple DataTree.ICreator copying the original tree and applying a custom function to its leafs retur...
Definition: ScalarCreator.m:18
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1