2 % simply random parameter set and snapshot generation
7 sim_data = detailed_simulation(model,model_data);
8 uh = model.get_dofs_from_sim_data(sim_data);
10 if ~isfield(model,
'RB_train_data_mode')
11 model.RB_train_data_mode = 'random';
14 detailed_data = model_data;
16 if ~isequal(model.RB_train_data_mode,'offline_greedy')
17 %%%% Lagrangian Dictionary for random or equidistant points
18 if isequal(model.RB_train_data_mode,'random')
19 mus = rand_uniform(model.RB_train_size,model.mu_ranges);
20 elseif isequal(model.RB_train_data_mode,'equidistant')
22 mu_dim = length(get_mu(model));
23 mus = zeros(mu_dim, model.RB_train_size);
25 mu_range = model.mu_ranges{i};
26 mus(i,:) = linspace(mu_range(1),mu_range(2),model.RB_train_size);
28 elseif isequal(model.RB_train_data_mode,
'points_given')
31 error('RB_train_dat_mode unknown');
33 RB = zeros(ndofs,model.RB_train_size);
34 for mui = 1:model.RB_train_size;
35 model = model.set_mu(model,mus(:,mui));
36 sim_data = detailed_simulation(model,model_data);
37 RB(:,mui) = model.get_dofs_from_sim_data(sim_data);
42 %%%%%%%%%%%%%%%%%%%%%%%%% Offline
Greedy
43 Mtrain = model.Mtrain;
44 ntrain = size(Mtrain,2);
47 tmp_detailed_data = model_data;
48 model.decomp_mode = 1; % == components
49 [tmp_detailed_data.A_comp, tmp_detailed_data.f_comp] = ...
50 model.operators(model,detailed_data);
51 tmp_detailed_data.RB = RB;
53 mus = zeros(size(Mtrain,1),0);
56 % take first basis vector arbitrary
58 %model = set_mu(model,Mtrain(:,i0));
59 %sim_data = detailed_simulation(model,model_data);
60 %RB = [RB,model.get_dofs_from_sim_data(sim_data)];
64 reduced_data = gen_reduced_data(model,tmp_detailed_data);
66 for N = 1:model.RB_stop_Nmax;
67 disp(['processing offline greedy extension ',num2str(N)]);
70 model = set_mu(model,Mtrain(:,i));
71 sim_data = rb_simulation(model,reduced_data);
72 % if res.res_norms(end)>res_max
73 % res_max = res.res_norms(end);
75 Delta = sim_data.Delta;
81 % take snapshot for worst parameter into basis
82 disp(['maximum Delta ',num2str(Delta_max)]);
83 if N>1 & Delta_max > Deltas_max(end)
84 disp('inspect workspace due to non-monotonicity!');
87 Deltas_max = [Deltas_max, Delta_max];
88 model = model.set_mu(model,Mtrain(:,i_max));
89 mu_indices = [mu_indices, i_max];
90 sim_data = detailed_simulation(model,model_data);
91 RB = [RB,model.get_dofs_from_sim_data(sim_data)];
92 tmp_detailed_data.RB = RB;
93 reduced_data = dictionary_extend_reduced_data(...
94 model,reduced_data,tmp_detailed_data);
96 % res.hs_res_norms_max = hs_res_norms_max;
97 detailed_data.RB_info.Mtrain = model.Mtrain;
98 detailed_data.RB_info.mu_indices = mu_indices;
99 detailed_data.RB_info.Deltas_max = Deltas_max;
100 %%%%%%%%%%%%%%%%%%%%%%%%% End Offline
Greedy
103 detailed_data.RB_info.mus = mus;
104 detailed_data.RB_info.time = toc;
105 detailed_data.RB = RB;
function detailed_data = dictionary_gen_detailed_data(model, model_data)
simply random parameter set and snapshot generation
Customizable implementation of an abstract greedy algorithm.