1 classdef EiReducedDataNode < Greedy.User.IReducedDataNode
3 % depending on collateral reduced basis space information only (e.g.
4 % interpolation DOFs and a local grid).
40 properties (SetAccess =
private, Dependent)
55 % constructor
for the generation of the reduced data.
58 % rmodel: of type NonlinEvol.ReducedModel
61 % Alternative synopsis:
63 % a reduced data node and (optionally) extracting smaller matrices.
69 copy_extract(rd, copy, rmodel);
71 fill_fields(rd, rmodel, detailed_data);
73 error('Did not find constructor for your arguments');
77 function conds = get_conds(this)
78 if ~isempty(this.Mmass)
79 conds.Mmass = condest(this.Mmass);
82 conds.BM = condest(this.BM);
85 function grid = get.grid(this)
86 grid = this.grid_local_ext;
89 function M = get.M(this)
90 M = size(this.BM, 2) - this.Mstrich;
93 function yesno = needs_subset_copy(this, rmodel)
94 % function yesno = needs_subset_copy(this, rmodel)
95 % @copybrief .Greedy.User.IReducedDataNode.needs_subset_copy()
97 % @copydetails .Greedy.User.IReducedDataNode.needs_subset_copy()
101 yesno = this.M ~= rmodel.M || this.Mstrich ~= rmodel.Mstrich;
105 methods(Access=private)
107 function fill_fields(this, rmodel, detailed_data)
108 model_data = detailed_data.model_data;
110 grid = model_data.grid;
112 this.BM = detailed_data.BM;
114 disp(['stencil mode: ' , rmodel.stencil_mode]);
115 disp(['stencil size: ' , num2str(rmodel.local_stencil_size)]);
118 eind = compute_TM_global(this, grid, detailed_data.TM, rmodel);
120 this.TM_global = eind;
123 this.grid_local_ext = gridpart(grid,eind);
124 % else % e.g. struct, or not required local grid:
125 % disp('please gen nice grid class for 1d grid...')
126 % reduced_ei_data.grid_local_ext{oi} = onedgrid_gridpart(grid,eind);
129 glob2loc = zeros(grid.nelements,1);
130 glob2loc(eind) = 1:length(eind);
131 this.TM_local = glob2loc(detailed_data.TM);
133 this.Mmass = detailed_data.QM
' * A * detailed_data.QM;
136 function copy_extract(this, reduced_data, rmodel)
137 MM = rmodel.M + rmodel.Mstrich;
138 if MM > reduced_data.M + reduced_data.Mstrich
139 error('M and M
'' too large
for current size of reduced basis!
');
142 grid = reduced_data.grid_local_ext;
144 % new version with external routine index_ext:
145 eind = compute_TM_global(this, grid, reduced_data.TM_local(1:MM), rmodel);
146 this.TM_global = eind;
147 this.grid_local_ext = gridpart(grid,eind);
149 glob2loc = zeros(grid.nelements,1);
150 glob2loc(eind) = 1:length(eind);
151 this.TM_local = glob2loc(reduced_data.TM_local(1:MM));
152 this.BM = reduced_data.BM(1:MM,1:MM);
153 this.Mmass = reduced_data.Mmass(1:MM,1:MM);
155 % get Q^t W Q for M to M+M'
156 if rmodel.Mstrich > 0
157 QWQ = this.Mmass(rmodel.M+1:end,MM);
158 this.factor = norm(QWQ);
165 methods (Access =
public)
166 function eind = compute_TM_global(this, grid, TM, rmodel)
167 if isequal(rmodel.stencil_mode, 'vertex')
168 mask = zeros(1, grid.nelements);
169 nbi = grid.NBI(TM,:);
171 % get indices of TM's neighbour-neighbours
172 nnbi = grid.NBI(unique(nbi(i)),:);
174 [nnbuniq,tally] = unique(sort(nnbi(ni)),'first');
175 tally = [tally(2:end);length(nnbi(ni))+1] - tally;
176 mask(nnbuniq) = tally;
179 mask(mask < 2) = 0; % skip the elements which have no vertex with the
180 % given elements in TM in common
183 eind = index_ext(grid, TM, rmodel.local_stencil_size);