1 function OK = test_rb_richards_fv
2 %
function OK = test_rb_richards_fv;
4 %
function generating a reduced basis
for the
richards_fv problem
for 15
5 % parameters. This tests the generation of a reduced basis that depends on an
6 % empirical interpolation of the
explicit operator. The test does a complete
7 % reduced basis simulation
for a parameter that is not in the training
8 % parameter
set and assures that the error is kept resonably small.
10 % OK == 1
if test is OK, otherwise 0
12 % Martin Drohmann 16.1.2009
16 % we make it somewhat faster by truncating the time interval and restricting
17 % the collateral and reduced basis to 20 resp. 10 elements.
19 params.model_type =
'test';
20 params.model_size =
'small';
24 bg_descr = richards_fv_bg_descr(params);
26 [dmodel, rbmodel] =
gen_models(descr, bg_descr);
28 model_data = gen_model_data(dmodel);
32 % constructing the collateral and the reduced basis
34 evalc(
'detailed_data = gen_detailed_data(rbmodel, model_data);');
37 disp(
'Basis generation failed');
38 disp(getReport(exception));
40 disp(
'basis generation terminated');
42 %model.M = cellfun(@(x)(size(x,2) - model.Mstrich), detailed_data.BM,
'UniformOutput',
true) - model.Mstrich;
44 rbdd = get_by_description(detailed_data.datatree,
'rb', rbmodel);
45 reduced_data = gen_reduced_data(rbmodel, rbdd);
46 disp(
'offline preparation terminated');
48 reduced_data = extract_reduced_data_subset(rbmodel, reduced_data);
49 disp(
'online preparation terminated');
51 set_mu(rbmodel, [0.5, 0.4]);
52 set_mu(dmodel, [0.5, 0.4]);
54 simulation_data = rb_simulation(rbmodel, reduced_data);
55 disp(
'rb simulaton terminated');
57 simulation_data = rb_reconstruction(rbmodel, rbdd, simulation_data);
58 disp(
'reconstruction finished');
60 sim_data = detailed_simulation(dmodel, model_data);
61 disp(
'detailed simulation finished');
63 err = dmodel.l2_error_sequence_algorithm(sim_data.U, simulation_data.U, model_data);
64 disp(
'error computation finished');
66 save(fullfile(rbmatlabhome,
'test',
'test_rb_richards_fv_data.mat'),
'rbmodel',
'detailed_data');
69 disp(
'error is too large!!!');