rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
rb_operators.m
1 function [LL_I, bb_I] = rb_operators(rmodel, detailed_data, decomp_mode)
2 %function [LL_I, bb_I] = rb_operators(rmodel, detailed_data, decomp_mode)
3 % function computing the time-dependent reduced basis operator and
4 % vector. If the decomposition mode is 'coefficients' (2), the detailed data
5 % are superfluous, can (and should for `H`-independence) be empty.
6 %
7 % required fields of descr:
8 % implicit_operators_algorithm: function_handle for computing the
9 % 'L_I','b_I'-operators with arguments '(grid, params)'.
10 % c.f. for example fv_operators_implicit()
11 % inner_product_name: name of inner-product function for
12 % discrete function l2-scalar-product
13 %
14 % Return values:
15 % LL_I: matrix, components or coefficients for implicit operator.
16 % bb_I: vector, components or coefficients for affine shift of implicit operator.
17 %
18 % Parameters:
19 % detailed_data: of type ::GreedyDataTreeDetailed.RBLeafNode
20 
21 % Bernard Haasdonk 23.7.2006
22 
23 % determine affine_decomposition_mode as integer
24 %decomp_mode = get_affine_decomp_mode(model);
25 
26 model = rmodel.descr;
27 model.decomp_mode = decomp_mode;
28 
29 if decomp_mode == 2
30 
31  [L_I, b_I] = model.implicit_operators_algorithm(model, []);
32 
33  % rb-operator coefficients can simply be forwarded
34  LL_I = L_I;
35  bb_I = b_I;
36 
37 else
38 
39  model_data = detailed_data.model_data;
40 
41  if decomp_mode == 0 % complete: simple projection on RB
42 
43  A = model_data.W;
44 
45  RBtranspA = detailed_data.RB' * A;
46 
47  % if isequal(params.model_type, 'implicit_nonaffine_linear')
48  % L_I = detailed_data.implicit_operator;
49  % b_I = detailed_data.implicit_constant;
50  % else
51  [L_I, b_I] = model.implicit_operators_algorithm(model, model_data);
52  % end
53 
54  % apply all operator contributions to RB:
55  L_I_RB = L_I * detailed_data.RB;
56 
57  % fill output quantities
58  % LL_I : matrix
59  LL_I = RBtranspA * L_I_RB;
60 
61  % bb : vector
62  bb_I = RBtranspA * b_I;
63 
64  elseif decomp_mode == 1
65 
66  if model.newton_solver || model.implicit_nonlinear
67  % disp('what is the use of the flag implicit_nonlinear ??');
68  % [dummy, b_I{1}] = fv_operators_diff_implicit(model, detailed_data, [], []);
69  L_I = cell(0,1);
70  b_I = cell(0,1);
71  else
72  [L_I, b_I] = model.implicit_operators_algorithm(model, ...
73  model_data);
74  end
75 
76  Q_L_I = size(L_I,1);
77  Q_b_I = length(b_I);
78 
79  RB = detailed_data.RB;
80  Nmax = size(RB,2);
81  A = model_data.W;
82 
83  RBtranspA = RB' * A;
84 
85  % init output quantities
86  % vectors:
87  bb_I = cell(Q_b_I,1);
88  bb_I(:) = {zeros(Nmax,1)};
89  % matrices:
90  LL_I = cell(Q_L_I,1);
91  LL_I(:) = {zeros(Nmax,Nmax)};
92 
93  % apply all operator contributions to RB:
94  L_I_RB = cell(Q_L_I,1);
95  L_I_RB(:) = {zeros(size(RB))};
96  for q=1:Q_L_I
97  L_I_RB{q}(:,:)= L_I{q} * RB;
98  end;
99 
100  % fill output quantities
101  % LL_I : matrices
102  for q = 1:Q_L_I;
103  LL_I{q} = RBtranspA * L_I_RB{q};
104  end;
105 
106  % bb_I : vectors
107  for q = 1:Q_b_I;
108  bb_I{q} = RBtranspA * b_I{q};
109  end;
110 
111  end
112 end;
113 
114 %| \docupdate
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1