2 %
function model = convdiff_dune_model(params)
3 % convection diffusion example
using dune-rb
for high dimensional computations
8 descr.name =
'convdiff_dune';
9 descr.rb_problem_type =
'LinEvolDune';
12 %% data that is definitely used outside of the detailed simulations
13 %% These values are now set in dunerbconvdiff(
'init_model')
15 if (~isempty(getenv('DUNERBHOME')))
16 addpath( fullfile( getenv('DUNERBHOME'), 'mexclient' ) );
17 addpath( getenv('DUNERBHOME') );
20 descr.mexptr = @mexclient;
22 is_connected = descr.mexptr('is_connected');
25 error('No connection to server!');
28 % server_params.serverhost = 'rbevol.uni-muenster.de'
29 % server_params.port = '1909'
30 % mexclient('init_server', server_params)
32 % copy model data from detailed dune-rb model
33 tmp_struct = descr.mexptr('init_model');
38 descr.T = tmp_struct.T;
39 descr.nt = tmp_struct.nt;
40 descr.dt = descr.T / descr.nt;
41 descr.mu_names = tmp_struct.mu_names;
42 descr.mu_ranges = tmp_struct.mu_ranges;
43 descr.mu = descr.mexptr('get_mu');
46 tmp = descr.mexptr('rb_symbolic_coefficients');
47 sym_coeffs = cell(1,4);
49 sym_coeffs{i} =
'@(mu) [ ';
50 for j = 1:size(tmp{i},2);
52 sym_coeffs{i} = [ sym_coeffs{i},
', ' ];
54 sym_coeffs{i} = [ sym_coeffs{i}, tmp{i}{j} ];
56 sym_coeffs{i} = [ sym_coeffs{i} ,
' ]' ];
59 sym_coeffs = cellfun(@eval, sym_coeffs,
'UniformOutput',
false);
62 descr.coeff_ops.LL_I_ptr = sym_coeffs{1};
63 descr.coeff_ops.LL_E_ptr = sym_coeffs{2};
64 descr.coeff_ops.bb_ptr = sym_coeffs{3};
65 descr.coeff_ops.u0_ptr = sym_coeffs{4};
67 descr.filecache_ignore_fields_in_model = {
'coeff_ops',
'mu'};
72 descr.data_const_in_time = 1;
74 descr.RB_train_num_intervals = 5;
76 descr.RB_val_size = 10;
78 descr.RB_stop_epsilon = 1e-8;
80 descr.RB_refinement_mode =
'adaptive';
82 %% choose generation mode
83 %descr.RB_generation_mode =
'greedy_uniform_fixed';
85 %% RB_generation_mode =
'random_fixed';
87 %% choose extension method
88 %descr.RB_extension_algorithm = @dune_RB_extension_PCA_fixspace;
90 %descr.RB_stop_timeout = 60*60; % 1 hour
91 %% stop on maximum number of base functions
92 %descr.RB_stop_Nmax = 30;
94 %descr.RB_stop_epsilon = 1e-9; % 0.003 is already realized by init data!!
95 %% stop on overfitting (needs a validation test set)
96 %descr.RB_stop_max_val_train_ratio = inf;
98 %%descr.RB_test_size = 1000;
100 %% fix the rand seed in
case of RB_generation_mode = random_fixed
101 %descr.RB_train_rand_seed = 0.5;
102 %% trainig set size in
case of RB_generation_mode = random_fixed
103 %descr.RB_train_size = 50;
105 %% choose the error indicator
106 %descr.RB_error_indicator =
'estimator'; % Delta from rb_simulation
108 % model.RB_error_indicator =
'error'; %
true error
110 function [mu] = dune_get_mu(model)
111 mu = model.mexptr('get_mu');
112 % if any(mu(:) ~= model.mu(:))
113 % warning(sprintf('mu values in RBmatlab and dune-rb differ! [%s != %s]', mat2str(mu(:)), mat2str(model.mu(:)) ) );
116 function reconstruct_and_compare(model, rb_sim_data)
117 model.mexptr('reconstruct_and_compare', rb_sim_data.a);
Reduced basis implementation for linear evolution equations.
Reduced data implementation for linear evolution problems with finite volume discretizations.
function descr = convdiff_dune_descr(params)
convection diffusion example using dune-rb for high dimensional computations and data structures ...
class generating the reduced basis space for the LinEvol problem with a Greedy algorithm.