rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
lin_evol_gen_detailed_data.m
1 function detailed_data=lin_evol_gen_detailed_data(model,model_data)
2 %function detailed_data=lin_evol_gen_detailed_data(model,model_data)
3 %
4 % method, which prepares reduced_data, which is meant as
5 % data, that may be dependent on H only, and is not required during the
6 % online-simulation, but it may be used for reconstruction purposes or
7 % computation of online_quantities. i.e. reduced basis vectors,
8 % colateral reduced basis spaces, grid, etc. can be stored here.
9 %
10 % So detailed_data is produced and used only in offline-phase algorithms.
11 %
12 % allowed dependency of data: H
13 % allowed dependency of computation: H
14 % Unknown at this stage: mu, Nmax, N
15 %
16 % Required fields of model:
17 % gridtype : rectgrid or triagrid to be generated
18 % mu_names : cell array of parameter-names
19 % mu_ranges : cell array of parameter-intervals
20 %
21 % Further fields are required for rb generation,
23 %
24 % generated fields of detailed_data:
25 %
26 % RB : reduced basis columns 1,...,Nmax
27 % grid : grid to be used in the subsequent stages
28 % RB_info : depending on generation method some detailed information
29 
30 % Bernard Haasdonk 15.5.2007
31 % edited by Dominik Garmatter 11.09 2012
32 
33 if(isempty(model_data))
34  model_data = gen_model_data(model);
35 end
36 detailed_data = [];
37 
38 %% begin of edit by Dominik Garmatter 11.09 2012
39 % components are now computet and stored in the detailed_data.
40 
41 if ~isfield(model, 'want_dual')
42  model.want_dual = 0;
43 end
44 % computing the operators dependant on the controlfield 'model.want_dual'
45 % 1 = dual Operators are computet, 0 = primal ones are.
46 % special Note: in the european_option_pricing model a functional named
47 % 'theta' includes a partial timederivative and therefore produces a
48 % slightly different dual problem. Therefore the 'theta'-case is sometimes
49 % treated differently. Don't care about this case if you don't use the
50 % european_option_pricing model.
51 model.decomp_mode = 1;
52 if model.want_dual % dual case
53  [~, ~, ~, detailed_data.L_I_comp, detailed_data.L_E_comp] = model.operators_ptr(model, model_data);
54  if strcmp(model.name_output_functional, 'theta') == 1
55  detailed_data.b_comp = model.operators_output(model, model_data); % v_l the Riesz_representant of the theta-functional
56  end
57 else % primal case
58  [detailed_data.L_I_comp, detailed_data.L_E_comp, detailed_data.b_comp] = model.operators_ptr(model, model_data);
59 end
60 %% end of edit
61 
62 skip_rb_generation = false;
63 detailed_data = structcpy(detailed_data, model_data);
64 if isfield(model_data, 'mexptr') && isfield(model, 'detailedfname')
65  if model_data.mexptr('is_valid_rb')
66  if exist(model.detailedfname, 'file')
67  tmp = load(model.detailedfname);
68  if length(tmp.detailed_data.RB) == model_data.mexptr('get_rb_size')
69  disp('loading already generated rb space!');
70  detailed_data = tmp.detailed_data;
71  skip_rb_generation = true;
72  else
73  model.mexptr('reset_rb');
74  end
75  else
76  model.mexptr('reset_rb');
77  end
78  end
79 end
80 if ~skip_rb_generation
81  detailed_data = rb_basis_generation(model,detailed_data);
82  if isfield(model, 'detailedfname')
83  save(model.detailedfname, 'model', 'detailed_data');
84  end
85 end
86 
87 
A triangular conforming grid in two dimensions.
Definition: triagrid.m:17
A cartesian rectangular grid in two dimensions with axis parallel elements.
Definition: rectgrid.m:17
function s1 = structcpy(s1, s2)
copies the fields of structure s2 into structure s1. If the field to be copied does not exist in s1 y...
Definition: structcpy.m:17
function detailed_data = rb_basis_generation(model, detailed_data)
reduced basis construction with different methods