rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
convdiff_dune_descr.m
Go to the documentation of this file.
1 function descr = convdiff_dune_descr(params)
2 % function model = convdiff_dune_model(params)
3 % convection diffusion example using dune-rb for high dimensional computations
4 % and data structures
5 
6 descr = LinEvol.descr_default;
7 
8 descr.name = 'convdiff_dune';
9 descr.rb_problem_type = 'LinEvolDune';
10 descr.RB_detailed_data_constructor = @LinEvol.DetailedData;
11 %descr.RB_reduced_data_constructor = @LinEvol.ReducedData;
12 %% data that is definitely used outside of the detailed simulations
13 %% These values are now set in dunerbconvdiff( 'init_model')
14 
15 if (~isempty(getenv('DUNERBHOME')))
16  addpath( fullfile( getenv('DUNERBHOME'), 'mexclient' ) );
17  addpath( getenv('DUNERBHOME') );
18 end
19 
20 descr.mexptr = @mexclient;
21 
22 is_connected = descr.mexptr('is_connected');
23 
24 if (~is_connected)
25  error('No connection to server!');
26 end
27 
28 % server_params.serverhost = 'rbevol.uni-muenster.de'
29 % server_params.port = '1909'
30 % mexclient('init_server', server_params)
31 
32 % copy model data from detailed dune-rb model
33 tmp_struct = descr.mexptr('init_model');
34 
35 %model.diffusion = 0;
36 %model.velocity
37 
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');
44 
45 
46 tmp = descr.mexptr('rb_symbolic_coefficients');
47 sym_coeffs = cell(1,4);
48 for i = 1:4
49  sym_coeffs{i} = '@(mu) [ ';
50  for j = 1:size(tmp{i},2);
51  if j > 1
52  sym_coeffs{i} = [ sym_coeffs{i}, ', ' ];
53  end
54  sym_coeffs{i} = [ sym_coeffs{i}, tmp{i}{j} ];
55  end
56  sym_coeffs{i} = [ sym_coeffs{i} , ' ]' ];
57 end
58 
59 sym_coeffs = cellfun(@eval, sym_coeffs, 'UniformOutput', false);
60 
61 descr.coeff_ops = [];
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};
66 
67 descr.filecache_ignore_fields_in_model = {'coeff_ops', 'mu'};
68 
69 descr.verbose = 1;
70 descr.debug = 0;
71 
72 descr.data_const_in_time = 1;
73 
74 descr.RB_train_num_intervals = 5;
75 
76 descr.RB_val_size = 10;
77 
78 descr.RB_stop_epsilon = 1e-8;
79 
80 descr.RB_refinement_mode = 'adaptive';
81 
82 %% choose generation mode
83 %descr.RB_generation_mode = 'greedy_uniform_fixed';
84 %% alternative:
85 %% RB_generation_mode = 'random_fixed';
86 
87 %% choose extension method
88 %descr.RB_extension_algorithm = @dune_RB_extension_PCA_fixspace;
89 %% stop timeout
90 %descr.RB_stop_timeout = 60*60; % 1 hour
91 %% stop on maximum number of base functions
92 %descr.RB_stop_Nmax = 30;
93 %% stop on epsilon
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;
97 
98 %%descr.RB_test_size = 1000;
99 
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;
104 
105 %% choose the error indicator
106 %descr.RB_error_indicator = 'estimator'; % Delta from rb_simulation
107 %% alternative:
108 % model.RB_error_indicator = 'error'; % true error
109 
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(:)) ) );
114 % end
115 
116 function reconstruct_and_compare(model, rb_sim_data)
117  model.mexptr('reconstruct_and_compare', rb_sim_data.a);
118 %| \docupdate
Reduced basis implementation for linear evolution equations.
Reduced data implementation for linear evolution problems with finite volume discretizations.
Definition: ReducedData.m:18
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.
Definition: DetailedData.m:18