rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
test_rb_richards_fv.m
1 function OK = test_rb_richards_fv
2 %function OK = test_rb_richards_fv;
3 %
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.
9 %
10 % OK == 1 if test is OK, otherwise 0
11 %
12 % Martin Drohmann 16.1.2009
13 
14 OK = 1;
15 
16 % we make it somewhat faster by truncating the time interval and restricting
17 % the collateral and reduced basis to 20 resp. 10 elements.
18 
19 params.model_type = 'test';
20 params.model_size = 'small';
21 params.verbose = 0;
22 
23 descr = richards_fv_descr(params);
24 bg_descr = richards_fv_bg_descr(params);
25 
26 [dmodel, rbmodel] = gen_models(descr, bg_descr);
27 
28 model_data = gen_model_data(dmodel);
29 
30 rbmodel.Mstrich = 1;
31 
32 % constructing the collateral and the reduced basis
33 try
34  evalc('detailed_data = gen_detailed_data(rbmodel, model_data);');
35 catch exception
36  OK = 0
37  disp('Basis generation failed');
38  disp(getReport(exception));
39 end
40 disp('basis generation terminated');
41 
42 %model.M = cellfun(@(x)(size(x,2) - model.Mstrich), detailed_data.BM, 'UniformOutput', true) - model.Mstrich;
43 
44 rbdd = get_by_description(detailed_data.datatree, 'rb', rbmodel);
45 reduced_data = gen_reduced_data(rbmodel, rbdd);
46 disp('offline preparation terminated');
47 
48 reduced_data = extract_reduced_data_subset(rbmodel, reduced_data);
49 disp('online preparation terminated');
50 
51 set_mu(rbmodel, [0.5, 0.4]);
52 set_mu(dmodel, [0.5, 0.4]);
53 
54 simulation_data = rb_simulation(rbmodel, reduced_data);
55 disp('rb simulaton terminated');
56 
57 simulation_data = rb_reconstruction(rbmodel, rbdd, simulation_data);
58 disp('reconstruction finished');
59 
60 sim_data = detailed_simulation(dmodel, model_data);
61 disp('detailed simulation finished');
62 
63 err = dmodel.l2_error_sequence_algorithm(sim_data.U, simulation_data.U, model_data);
64 disp('error computation finished');
65 
66 save(fullfile(rbmatlabhome, 'test', 'test_rb_richards_fv_data.mat'), 'rbmodel', 'detailed_data');
67 
68 if err(end) > 1e-3;
69  disp('error is too large!!!');
70  OK = 0;
71 end;
72 
73 %| \docupdate