rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
EiReducedDataNode.m
1 classdef EiReducedDataNode < Greedy.User.IReducedDataNode
2  % Implementation of a Greedy.User.IReducedDataNode storing reduced data
3  % depending on collateral reduced basis space information only (e.g.
4  % interpolation DOFs and a local grid).
5 
6  properties
8  %
10  BM;
11 
13  %
15  grid_local_ext;
16 
18  %
20  TM_local;
21 
23  %
25  TM_global;
26 
28  %
30  Mmass;
31 
33  %
35  Mstrich = 0;
36 
37  % an object of type ILocalizedOperator for which the empirical
38  % interpolation basis was generated.
39  ophandle;
40 
41  id;
42 
43  gEI;
44 
45  gn_edges;
46 
47  gn_inner_edges;
48 
49  gn_boundary_edges;
50 
51  TM_global_args;
52 
53  TM_reduction_args = {};
54  end
55 
56  properties (SetAccess = private, Dependent)
58  %
60  M;
61 
63  %
65  grid;
66  end
67 
68  methods
69  function rd = EiReducedDataNode(rmodel, detailed_data)
70  % function rd = EiReducedDataNode(rmodel, detailed_data)
71  % constructor for the generation of the reduced data.
72  %
73  % Parameters:
74  % rmodel: of type TwoPhaseFlow.ReducedModel
75  % detailed_data: of type IDetailedData
76  %
77  % Alternative synopsis:
78  % @code EiReducedDataNode(rmodel, ei_reduced_data_node) @endcode copying
79  % a reduced data node and (optionally) extracting smaller matrices.
80  if nargin == 0
81  error('TwoPhaseFlow.EiReducedDataNode constructor needs an argument');
82  elseif nargin == 2 && isa(rmodel, 'IReducedModel') ...
83  && isa(detailed_data, 'TwoPhaseFlow.EiReducedDataNode')
84  copy = detailed_data;
85  copy_extract(rd, copy, rmodel);
86  elseif nargin == 2
87  fill_fields(rd, rmodel, detailed_data);
88  else
89  error('Did not find constructor for your arguments');
90  end
91  end
92 
93  function conds = get_conds(this)
94  if ~isempty(this.Mmass)
95  conds.Mmass = condest(this.Mmass);
96  end
97  if ~isempty(this.BM)
98  conds.BM = condest(this.BM);
99  end
100  end
101  function grid = get.grid(this)
102  grid = this.grid_local_ext;
103  end
104 
105  function M = get.M(this)
106  M = size(this.BM, 2) - this.Mstrich;
107  end
108 
109  function yesno = needs_subset_copy(this, rmodel)
110  % function yesno = needs_subset_copy(this, rmodel)
111  % @copybrief ::GreedyUser.IReducedDataNode.needs_subset_copy()
112  %
113  % @copydetails ::GreedyUser.IReducedDataNode.needs_subset_copy()
114  %
115  % Parameters:
116  % rmodel: of type TwoPhaseFlow.ReducedModel
117 
118  MM = get_by_description(rmodel.M, this.ophandle.id);
119  yesno = isempty(MM) || (this.M ~= MM);
120  end
121 
122  end
123  methods(Access=private)
124 
125  function fill_fields(this, rmodel, detailed_data)
126  model_data = detailed_data.model_data;
127  if size(model_data.W, 1) == size(detailed_data.QM, 1)
128  A = model_data.W;
129  else
130  A = model_data.diamondW;
131  end
132 
133  this.ophandle = detailed_data.ophandle;
134  MM = get_by_description(rmodel.M, this.ophandle.id);
135  this.BM = detailed_data.BM(1:MM,1:MM);
136 
137  [nmd, eind, eind_local] = this.ophandle.compute_TM_global(model_data, detailed_data.TM(1:MM));
138 
139  this.grid_local_ext = nmd.grid_local_ext;
140  this.TM_global_args = nmd.TM_global_args;
141  this.gEI = nmd.gEI;
142  this.gn_edges = nmd.gn_edges;
143  this.gn_inner_edges = nmd.gn_inner_edges;
144  this.gn_boundary_edges = nmd.gn_boundary_edges;
145  this.TM_global = eind;
146  this.TM_local = eind_local;
147 
148  this.Mmass = detailed_data.QM(:,1:MM)' * A * detailed_data.QM(:,1:MM);
149  end
150 
151  function copy_extract(this, reduced_data, rmodel)
152  this.ophandle = reduced_data.ophandle;
153  this.id = reduced_data.id;
154 
155  MM = get_by_description(rmodel.M, this.ophandle.id);
156 
157  grid = reduced_data.grid_local_ext;
158 
159  % new version with external routine index_ext:
160  [nmd, eind, eind_local] = this.ophandle.compute_TM_global(reduced_data, reduced_data.TM_local(1:MM));
161 
162  reduced_data_subset.TM_global = reduced_data.TM_global(1:MM);
163  reduced_data_subset.grid_local_ext = nmd.grid_local_ext;
164  [this.gEI, this.gn_inner_edges, this.gn_boundary_edges] ...
165  = compute_edge_indices(reduced_data_subset.grid_local_ext);
166  this.gn_edges = this.gn_inner_edges + this.gn_boundary_edges;
167 
168  glob2loc = zeros(grid.nelements,1);
169  glob2loc(eind) = 1:length(eind);
170  this.TM_global_args = cell(1, length(nmd.TM_global_args));
171  for i = 1:length(nmd.TM_global_args)
172  oldTM_global = reduced_data.TM_global_args{i};
173  this.TM_global_args{i} = oldTM_global(nmd.TM_global_args{i});
174  this.TM_reduction_args{i} = nmd.TM_global_args{i};
175  end
176  this.TM_local = glob2loc(reduced_data.TM_local(1:MM));
177  this.BM = reduced_data.BM(1:MM,1:MM);
178  this.Mmass = reduced_data.Mmass(1:MM,1:MM);
179 
180  % get Q^t W Q for M to M+M'
181  if rmodel.Mstrich > 0
182  QWQ = this.Mmass(rmodel.M+1:end,MM);
183 % this.factor = norm(QWQ);
184  else
185 % this.factor = NaN;
186  end
187  end
188  end
189 end
Interface for a localized operator that fulfills the so-called -independent DOF dependence.
function [ gEI , in_edges , b_edges , i_ints_bigger , b_ints ] = compute_edge_indices(gridbase grid)
edge index matrix. This matrix maps each edge specified by the tuple (element_id, local_edge_id) to a...
gridbase grid
synonym for grid_local_ext
Mstrich
number of collateral reduced basis vectors used for error estimation.
reduced model for non-linear evolution problems as given by a TwoPhaseFlow.DetailedModel.
Definition: ReducedModel.m:18
M
number of collateral reduced basis vectors stored in this data node.
gridbase grid_local_ext
local grid with added neighbours such that a sparse evaluation of the empirically interpolated operat...
TM_local
indices of grid entities in the grid_local_ext structure where the interpolation points are situated...
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...
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
TM_global
indices of grid entities in the the global grid structure where the interpolation points are situated...
BM
empirical interpolation matrix
Mmass
empirical interpolation mass matrix.
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