rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
rb_init_values_separable.m
Go to the documentation of this file.
1 function a0 = rb_init_values_separable(rmodel, detailed_data, decomp_mode)
2 %function a0 = rb_init_values_separable(rmodels,detailed_data,decomp_mode)
3 % function computing initial values for a reduced simulation.
4 %
5 % This function can be used in case the initial values function `u_0(\mu)` is
6 % parameter separable, i.e. has the form
7 % ``u_0(x;\mu) = \sum_{q=1}^{Q_{u_0}} \sigma^q_{u_0}(\mu) u_0^q(x)``.
8 %
9 % Depending on the argument 'decomp_mode', this function returns:
10 % - 'decomp_mode == 0': `{\cal M}_{\text{red}}[u_0(\cdot;\mu)]`
11 % - 'decomp_mode == 1': `\left\{ {\cal M}_{\text{red}}[u_0^q(\cdot)] \right\}_{q=1}^{Q_{u_0}}`
12 % - 'decomp_mode == 2': `\left\{ \sigma^q(\mu) \right\}_{q=1}^{Q_{u_0}}`
13 %
14 % If the decomposition mode is '2 == coefficients', the detailed_data are
15 % superfluous, can (and should for `H`-independence) be empty.
16 %
17 % Parameters:
18 % detailed_data: detailed data tree leaf object of type Greedy.DataTree.Detailed.RBLeafNode .
19 % rmodel: reduced model of type IReducedModel .
20 %
21 % Required fields of rmodel:
22 % init_values_algorithm: name of function for computing the
23 % detailed initvalues-DOF with arguments (grid, params)
24 % - example: fv_init_values()
25 %
26 % Return values:
27 % a0: coefficient vector of size '1 x N' for the initial values.
28 
29 % Bernard Haasdonk 23.7.2006
30 
31 % determine affine_decomposition_mode as integer
32 
33 if isa(rmodel, 'IModel')
34  model = rmodel.descr;
35 else
36  model = rmodel;
37 end
38 model.decomp_mode = decomp_mode;
39 
40 if decomp_mode == 2
41  u0 = model.init_values_algorithm(model, []);
42  a0 = u0;
43 else
44 
45  if isa(detailed_data, 'IDetailedData')
46  model_data = detailed_data.model_data;
47  else
48  model_data = detailed_data;
49  end
50 
51  if decomp_mode == 0 % complete: simple projection on RB
52  u0 = model.init_values_algorithm(model,model_data);
53  A = model_data.W;
54  a0 = u0' * A * detailed_data.RB;
55  %a0 = feval(params.inner_product_name, ...
56  % detailed_data.RB,u0,detailed_data.grid,params);
57  % equivalent for fv: a0 = (RB.*repmat(grid.A(:),1,Nmax))' * u0(:);
58  elseif decomp_mode == 1
59  Nmax = size(detailed_data.RB,2);
60  u0 = model.init_values_algorithm(model,model_data);
61  Q_u0 = length(u0);
62  a0 = cell(Q_u0,1);
63  a0(:) = {zeros(Nmax,1)};
64  % a0 : initial data projected on RB set: starting coefficients
65  A = model_data.W;
66  for q=1:Q_u0
67  a0{q} = u0{q}' * A * detailed_data.RB;
68  end;
69  if model.debug && length(u0) > 1
70  if max(abs(detailed_data.RB * a0{1}'-u0{1}))>0.001
71  U0 = [u0{1},u0{2}];
72  U0_RB = [detailed_data.RB*a0{1}',detailed_data.RB*a0{2}'];
73  plot_params = [];
74  plot_params.plot = model.plot;
75  plot_params.title = 'U0 Components';
76  plot_sequence(U0,model_data.grid,plot_params);
77  plot_params.title = 'U0_RB';
78  plot_sequence(U0_RB,model_data.grid,plot_params);
79  error('rb initial data badly approximating initial data!!');
80  end
81  end
82  end
83 end
84 
85 %| \docupdate
This is the common interface for all models, detailed and reduced ones.
Definition: IModel.m:17
function a0 = rb_init_values_separable(IReducedModel rmodel,Greedy.DataTree.Detailed.RBLeafNode detailed_data, decomp_mode)
function computing initial values for a reduced simulation.
function p = plot_sequence(varargin)
plotting a sequence of data slices on polygonal 2d grid (constructed from params if empty) and provid...
Definition: plot_sequence.m:17
Definition: leaf.m:17
This is the interface for a reduced model providing methods to compute low dimensional reduced simula...
Definition: IReducedModel.m:17
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1
Interface class for the generation and storage of reduced basis spaces as described in Module (M2)...
Definition: IDetailedData.m:17