3 % method which modifies reduced_data, which is the data, that will
4 % be passed to the online-simulation algorithm.
6 % Typically,
this routine only does a submatrix extraction of the
7 %
'reduced_data.M',
'reduced_data.N' sized offline-objects to produce
8 %
'model.M',
'model.N' sized objects
for the real simulation.
10 % Required fields of model:
11 % N : number of reduced basis vectors to choose
12 % M : number of collateral reduced basis vectors to choose
for the
15 % Optional fields of model:
16 % Mstrich : number of collateral reduced basis vectors to choose
for the
17 % a posteriori error estimator (
default = 0)
19 % Optional fields of reduced_data:
20 % a0 : a cell array sequence of N-vector components of initial data
22 % LL_E : a cell array sequence of N x N component-Matrices of
explicit
23 %
operator evaluations.
24 % LL_I : a cell array sequence of N x N component-Matrices of implicit
25 %
operator evaluations.
26 % bb : a cell array sequence of N-vector components of the offset
27 % bb_I : a cell array sequence of N-vector components of the implicit offset
28 % K_II : a cell array sequence sequence of N x N matrices
29 % K_IE : a cell array sequence of N x N matrices
30 % K_EE : a cell array sequence of N x N matrices
31 % m_I : a cell array sequence of N-vector components of offset
32 % m_E : a cell array sequence of N-vector components of offset
33 % m : a cell array sequence of scalars (simply copied from
'reduced_data')
34 % CE : N x M interpolation matrix
35 % grid_local_ext : part of the grid containing the cells
'TM' plus their
36 % neighbours to be used
for local
operator evaluation
37 % TM_local : indices of magic-point-elements in the locally extended
39 % RB_local_ext : reduced basis vector values restricted to the support of
41 % s_RB : in
case of a given output functional,
this is a vector of
42 % output functional values of the reduced basis
43 % s_l2norm : in
case of a given output functional,
this is the
44 % `L^2`-norm of the output functional
45 % BM :
'M x M' interpolation matrix of empirical interpolation.
46 % DE :
'N x M' cross correlation matrix between
'detailed_data.QM' and
48 % Mmass :
'M x M' mass matrix computed from
'detailed_data.QM' vectors
50 % generated fields of reduced_data_subset:
51 % a0 : a cell array sequence of N-vector components of initial data
53 % LL_E : a cell array sequence of N x N component-Matrices of
explicit
54 %
operator evaluations.
55 % LL_I : a cell array sequence of N x N component-Matrices of implicit
56 %
operator evaluations.
57 % bb : a cell array sequence of N-vector components of the offset
58 % bb_I : a cell array sequence of N-vector components of the implicit offset
59 % K_II : a cell array sequence sequence of N x N matrices
60 % K_IE : a cell array sequence of N x N matrices
61 % K_EE : a cell array sequence of N x N matrices
62 % m_I : a cell array sequence of N-vector components of offset
63 % m_E : a cell array sequence of N-vector components of offset
64 % m : a cell array sequence of scalars (simply copied from
'reduced_data')
65 % CE : N x M interpolation matrix
66 % grid_local_ext : part of the grid containing the cells TM plus their
67 % neighbours to be used
for local
operator evaluation
68 % TM_local : indices of magic-point-elements in the locally extended
70 % RB_local_ext : reduced basis vector values restricted to the support of
72 % s_RB : in
case of a given output functional,
this is a vector of
73 % output functional values of the reduced basis
74 % s_l2norm : in
case of a given output functional,
this is the
75 % `L^2`-norm of the output functional
78 % Bernard Haasdonk 16.5.2008
80 reduced_data_subset = reduced_data;
82 if ~isfield(model,
'stencil_mode')
83 stencil_mode = 'edge';
85 stencil_mode = model.stencil_mode;
88 if ~isfield(model, 'Mstrich')
92 if model.N ~= reduced_data.N || any(model.M ~= reduced_data.M) ...
93 || model.Mstrich ~= reduced_data.Mstrich
95 % extract correct N-sized submatrices and subvectors from reduced_data
96 if model.N > length(reduced_data.a0{1})
97 error(
'N too large for current size of reduced basis!');
101 Mstrich = model.Mstrich;
102 if isfield(reduced_data,
'a0')
103 reduced_data_subset.a0 = subblock_sequence(reduced_data.a0,1:N);
105 if isfield(reduced_data, 'LL_I')
106 reduced_data_subset.LL_I = subblock_sequence(reduced_data.LL_I,1:N,1:N);
108 if isfield(reduced_data, 'LL_E')
109 reduced_data_subset.LL_E = subblock_sequence(reduced_data.LL_E,1:N,1:N);
111 if isfield(reduced_data, 'bb')
112 reduced_data_subset.bb = subblock_sequence(reduced_data.bb,1:N);
114 if isfield(reduced_data, 'bb_I')
115 reduced_data_subset.bb_I = subblock_sequence(reduced_data.bb_I,1:N);
117 if isfield(reduced_data, 'K_EE')
118 reduced_data_subset.K_EE = subblock_sequence(reduced_data.K_EE,1:N,1:N);
120 if isfield(reduced_data, 'K_IE')
121 reduced_data_subset.K_IE = subblock_sequence(reduced_data.K_IE,1:N,1:N);
123 if isfield(reduced_data, 'K_II')
124 reduced_data_subset.K_II = subblock_sequence(reduced_data.K_II,1:N,1:N);
126 if isfield(reduced_data, 'm_I')
127 reduced_data_subset.m_I = subblock_sequence(reduced_data.m_I,1:N);
129 if isfield(reduced_data, 'm_E')
130 reduced_data_subset.m_E = subblock_sequence(reduced_data.m_E,1:N);
132 if isfield(reduced_data, 'm')
133 reduced_data_subset.m = reduced_data.m;
135 if isfield(reduced_data, 'Nmass')
136 reduced_data_subset.Nmass = reduced_data.Nmass(1:N,1:N);
139 if isfield(reduced_data, 'BM')
141 reduced_data_subset.factor = cell(size(reduced_data.BM));
143 for oi = 1:length(reduced_data.BM(:))
144 Mmax = length(reduced_data.TM_local{oi});
145 MM = M(oi) + Mstrich;
147 error(
'M + Mstrich > Mmax');
149 reduced_data_subset.DE{oi} = reduced_data.DE{oi}(1:N,1:MM);
150 grid = reduced_data.grid_local_ext{oi};
152 if strcmp(stencil_mode,
'vertex') == 1
153 mask = zeros(1,grid.nelements);
154 nbi = grid.NBI(reduced_data.TM_local{oi}(1:MM),:);
157 %
get indices of TM
's neighbour-neighbours
158 nnbi = grid.NBI(unique(nbi(i)),:);
160 [nnbuniq,tally] = unique(sort(nnbi(ni)),'first
');
161 tally = [tally(2:end);length(nnbi(ni))+1] - tally;
162 mask(nnbuniq) = tally;
164 mask(reduced_data.TM_local{oi}(1:MM)) = 6;
166 % disp('workaround
for Frederikes model
')
167 % mask(mask < 1) = 0; % here second neighbours are generated!
171 % new version with external routine index_ext:
174 reduced_data.TM_local{oi}(1:MM),...
175 model.local_stencil_size);
180 reduced_data_subset.grid_local_ext{oi} = gridpart(grid,eind);
182 reduced_data_subset.RB_local_ext{oi} = reduced_data.RB_local_ext{oi}(eind,1:N);
184 % the following messes up the order of the ei-functions!!
185 %reduced_data.TM_local = find(mask(eind)==2);
187 %goal TM_local(1) is the local element number, which corresponds to
188 %the original one, i.e. eind(TM_local(i)) = TM(i)
190 % create kind of 'inversion
' map
192 % eind : 1:M_local_ext => 1:H
194 glob2loc = zeros(grid.nelements,1);
195 glob2loc(eind) = 1:length(eind);
196 reduced_data_subset.TM_local{oi} = glob2loc(reduced_data.TM_local{oi}(1:MM));
197 reduced_data_subset.BM{oi} = reduced_data.BM{oi}(1:MM,1:MM);
198 reduced_data_subset.Mmass{oi} = reduced_data.Mmass{oi}(1:MM,1:MM);
201 % get Q^t W Q for M to M+M'
203 QWQ = reduced_data_subset.Mmass{oi}(M(oi)+1,MM);
204 reduced_data_subset.factor{oi} = norm(QWQ);
206 reduced_data_subset.factor{oi} = NaN;
208 %
if the velocity file is based on a file, the corresponding
209 % subsets must be extracted here:
210 % in
case of file access, the correct filename must be set here
211 % the following is only relevant in
case of use of a
212 % model.use_velocitymatrix_file and filecaching mode 2
213 if isfield(model,
'filecache_velocity_matrixfile_extract') && ...
214 (model.filecache_velocity_matrixfile_extract == 2);
215 % change global velocity file to MMax velocity file generated in
217 if Mmax ~= model.Mmax
218 error(
'Mmax in model and reduced_data does not correspond!!');
220 model.velocity_matrixfile = ...
221 [
'gridpart_Mmax',num2str(Mmax),
'_',model.velocity_matrixfile];
222 % generate M velocity file
if not existing
223 cache_velocity_matrixfile_extract(model, ...
224 reduced_data_subset.grid_local_ext{1}.ECX(:,:),...
225 reduced_data_subset.grid_local_ext{1}.ECY(:,:),...
226 [
'M',num2str(model.M(oi))]);
231 if isfield(model,
'name_output_functional')
232 reduced_data_subset.s_RB = reduced_data.s_RB(1:N);
233 reduced_data_subset.s_l2norm = reduced_data.s_l2norm;
237 reduced_data_subset.N = N;
238 reduced_data_subset.M = M;
239 reduced_data_subset.Mstrich = Mstrich;
240 if isfield(reduced_data, 'time_split_map')
241 reduced_data_subset.time_split_map = reduced_data.time_split_map;
function reduced_data_subset = nonlin_evol_reduced_data_subset(model, reduced_data)
method which modifies reduced_data, which is the data, that will be passed to the online-simulation a...