3 % method which produces reduced_data, which is the data, that will be passed to
6 % Therefore, no quantities dependent on the high-dimension `H` may be included
7 % here. Neither may online-data include parameter-dependent `\mu`-quantities.
8 % So no complete grid or detailed solutions or reduced basis vectors may be
9 % stored here. So online data is produced in the offline stage, but may be used
10 % in online-stages. So the computation time may depend on `H`, but the results
11 % may not depend on
this complexity.
13 % allowed dependency of generated data:
16 % not allowed dependency of data:
18 % allowed dependency of computation:
22 % Unknown at
this stage:
25 % Generated fields of reduced_data:
26 % a0 : a cell array sequence of N-vector components of initial data
28 % LL_E : a cell array sequence of N x N component-Matrices of
explicit
29 %
operator evaluations.
30 % LL_I : a cell array sequence of N x N component-Matrices of implicit
31 %
operator evaluations.
32 % bb_I : a cell array sequence of N-vector components of the implicit offset
33 % DE :
'Nmax x Mmax' cross correlation matrix between
'detailed_data.QM'
34 % and
'detailed_data.RB'
35 % BM :
'Mmax x Mmax' interpolation matrix of empirical interpolation.
36 % grid_local_ext : part of the grid containing the cells
'TM' plus their
37 % neighbours to be used
for local
operator evaluation
38 % TM_local : indices of magic-point-elements in the grid_local_ext
39 % RB_local_ext : reduced basis vector values restricted to the support of
43 % Bernard Haasdonk 16.5.2007
49 if ~isfield(model,
'stencil_mode')
50 stencil_mode = 'edge';
52 stencil_mode = model.stencil_mode;
56 disp(['stencil mode: ' , model.stencil_mode]);
57 disp(['stencil size: ' , num2str(model.local_stencil_size)]);
60 model.decomp_mode = 1;
61 reduced_data.a0 = model.rb_init_values(model, detailed_data);
62 Nmax = size(detailed_data.RB,2);
63 Mmax = size(detailed_data.QM{1},2);
65 % assuming that components
do not change in time, so wlg t = 0!!!
67 [reduced_data.LL_I, reduced_data.bb_I] = ...
68 model.rb_operators(model, detailed_data);
72 reduced_data.Nmass = detailed_data.RB
' * A * detailed_data.RB;
74 reduced_data.DE = cell(size(detailed_data.QM));
75 reduced_data.BM = cell(size(detailed_data.QM));
76 reduced_data.grid_local_ext = cell(size(detailed_data.QM));
77 reduced_data.RB_local_ext = cell(size(detailed_data.QM));
78 reduced_data.TM_local = cell(size(detailed_data.QM));
79 reduced_data.Mmass = cell(size(detailed_data.QM));
81 for oi = 1:length(detailed_data.QM(:))
82 reduced_data.DE{oi} = detailed_data.RB' * A * detailed_data.QM{oi};
84 reduced_data.BM{oi} = detailed_data.BM{oi};
86 % determine indices of TMmax and its neighbours
87 grid = detailed_data.grid;
88 TM = detailed_data.TM{oi};
89 if strcmp(stencil_mode,
'vertex') == 1
90 mask = zeros(1, grid.nelements);
93 %
get indices of TM
's neighbour-neighbours
94 nnbi = grid.NBI(unique(nbi(i)),:);
96 [nnbuniq,tally] = unique(sort(nnbi(ni)),'first
');
97 tally = [tally(2:end);length(nnbi(ni))+1] - tally;
98 mask(nnbuniq) = tally;
101 mask(mask < 2) = 0; % skip the elements which have no vertex with the
102 % given elements in TM in common
105 eind = index_ext(grid,TM,model.local_stencil_size);
109 reduced_data.grid_local_ext{oi} = gridpart(grid,eind);
110 % else % e.g. struct, or not required local grid:
111 % disp('please gen nice grid
class for 1d grid...')
112 % reduced_data.grid_local_ext{oi} = onedgrid_gridpart(grid,eind);
115 reduced_data.RB_local_ext{oi} = detailed_data.RB(eind,:);
116 reduced_data.implicit_crb_index = detailed_data.implicit_crb_index;
117 reduced_data.explicit_crb_index = detailed_data.explicit_crb_index;
119 % the following messes up the order of the ei-functions!!
120 %reduced_data.TM_local = find(mask(eind)==2);
122 %goal TM_local(1) is the local element number, which corresponds to
123 %the original one, i.e. eind(TM_local(i)) = TM(i)
125 % create kind of 'inversion' map
127 % eind : 1:M_local_ext => 1:H
129 glob2loc = zeros(grid.nelements,1);
130 glob2loc(eind) = 1:length(eind);
131 reduced_data.TM_local{oi} = glob2loc(detailed_data.TM{oi});
133 % generate grid_local velocity file,
if the flux is based on a file:
134 % in
case of file access, the correct filename must be set here
135 % the following is only relevant in
case of use of a
136 % params.use_velocitymatrix_file and filecaching mode 2
137 if isfield(model,
'filecache_velocity_matrixfile_extract') && ...
138 (model.filecache_velocity_matrixfile_extract == 2);
139 cache_velocity_matrixfile_extract(model, ...
140 reduced_data.grid_local_ext{1}.ECX(:,:),...
141 reduced_data.grid_local_ext{1}.ECY(:,:),...
142 [
'M',num2str(model.M),
'_',
'gridpart_Mmax',num2str(Mmax)]);
145 % may be needed by a posteriori error estimator: the CRB mass matrix Q^t W Q
146 reduced_data.Mmass{oi} = detailed_data.QM{oi}
' * ...
147 model.get_inner_product_matrix(detailed_data) * detailed_data.QM{oi};
149 % add the localext2global mapping:
150 %reduced_data.local_ext_2_global = eind;
152 % check correspondence!
153 %disp('Check TM-local-global correspondence. Remove later...
');
154 %for i = 1:length(detailed_data.TM)
155 % if (eind(reduced_data.TM_local(i)) ~= detailed_data.TM(i))
156 % error('local T_M numbers confused!!!
');
160 % for debugging: add mass-matrix
161 %disp('temporary mass matrix is added
');
162 %reduced_data.M = detailed_data.RB' * A * detailed_data.RB;
165 if(isfield(detailed_data,
'time_split_map'))
166 reduced_data.time_split_map = detailed_data.time_split_map;
168 reduced_data.N = model.get_rb_size(model, detailed_data);
169 reduced_data.M = cellfun(@(x) size(x,2), detailed_data.QM);
170 reduced_data.Mstrich = 0;
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
function reduced_data = nonlin_evol_gen_reduced_data(model, detailed_data, params)
method which produces reduced_data, which is the data, that will be passed to an online-algorithm.
A triangular conforming grid in two dimensions.
A cartesian rectangular grid in two dimensions with axis parallel elements.
a one dimensional grid implementation