rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
elastic_rope_model.m
1 function model = elastic_rope_model(params)
2 %function model = elastic_rope_model(params)
3 %
4 % model according to the first example of the experiments in "A
5 % Reduced Basis Method for Paramterized Variational Inequalities"
6 % (B.Haasdonk, J.Salomon, B.Wohlmuth).
7 %
8 % params.xnumintervals: number of intervals, i.e. 200 for paper
9 
10 % I.Maier, B. Haasdonk 30.05.2011
11 
12 if nargin < 1
13  params = [];
14 end;
15 if ~isfield(params,'xnumintervals');
16  params.xnumintervals = 202;
17 end;
18 if ~isfield(params,'xrange');
19  params.xrange = [0,1];
20 end;
21 
22 model.xrange = params.xrange;
23 model.xnumintervals = params.xnumintervals;
24 model.decomp_mode = 0;
25 model.RB_generation_mode = 'enrichment_by_supremizers';
26 model.mu_names = {'mu_1','mu_2'};
27 model.mu_ranges = {[10,50]/200,[-0.05,0.5]};
28 
29 model.set_mu = @set_mu_default;
30 model.get_mu = @get_mu_default;
31 
32 % default mu-values
33 model.mu_1 = 21.7157/200;
34 model.mu_2 = 0.1111;
35 model.mu_fix = 30/200;
36 
37 % function pointers
38 model.gen_model_data = @vi_gen_model_data;
39 model.detailed_simulation = @vi_detailed_simulation;
40 model.gen_detailed_data = @vi_gen_detailed_data;
41 model.gen_reduced_data = @vi_gen_reduced_data;
42 model.reduced_data_subset = @vi_reduced_data_subset;
43 model.rb_simulation = @vi_rb_simulation;
44 model.rb_reconstruction = @vi_rb_reconstruction;
45 model.plot_sim_data = @vi_plot_sim_data;
46 model.plot_detailed_data = @vi_plot_detailed_data;
47 model.get_rb_size = @(model,detailed_data) size(detailed_data.RB_U,2);
48 model.get_dofs_from_sim_data = @(sim_data) sim_data.U;
49 model.is_stationary = 1;
50 model.gridtype = 'onedgrid';
51 
52 model.operators = @elastic_rope_operators;
53 model.get_inner_product_matrix = @standard_inner_product_matrix;
54 model.get_supremizer_matrix = @elastic_rope_supremizer_matrix;
55 
56 % data functions
57 obstacle_coefficients = @(dummy,params) [1; params.mu_2];
58 obstacle_components = @(glob,params) ...
59  {-0.2*(sin(pi*glob) - sin(3*pi*glob)) - 0.5, (glob-1/2)};
60 model.obstacle = @(glob,params) ...
61  eval_affine_decomp_general(obstacle_components, ...
62  obstacle_coefficients,glob,params);
63 %%% inf-sup, coercivity and continuity constant
64 model.beta_b = 1;
65 model.alpha_a = @(model) min(model.mu_1,model.mu_fix);
66 model.gamma_a = @(model) max(model.mu_1,model.mu_fix);
67 % discretization parameter
68 %model.H = params.H;
69 model.enable_error_estimator = 0;
70 
71 % parameter for the snaphots computation
72 model.RB_numintervals = [4, 4];
73 
74 % parameter for making work with new descr
75 model.descr = [];
76 
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 % auxiliary functions
79 
80 function K = standard_inner_product_matrix(model,model_data)
81 %function K = standard_inner_product_matrix(model,model_data)
82 K = 1/model_data.dx * (-diag(ones(1,model.xnumintervals-2),-1) + ...
83  2*eye(model.xnumintervals-1) ...
84  -diag(ones(1,model.xnumintervals-2),1));
85 
86 function [A,B,f,g] = elastic_rope_operators(model,model_data)
87 %function [A,B,f,g] = elastic_rope_operators(model,model_data)
88 %
89 % provides offline/online decomposition
90 
91 val_fix = model.mu_fix;
92 
93 if model.decomp_mode == 2
94  A = [model.mu_1; val_fix];
95  B = 1;
96  f = 1;
97  g = model.obstacle([0,0],model);
98 
99 else
100 
101  dx = model_data.dx;
102  H = model.xnumintervals -1;
103 
104  A_2 = (-diag(ones(1,H-1),-1) + 2*eye(H) - diag(ones(1,H-1),1)) / ...
105  dx;
106  A_1 = A_2;
107 
108  ind = find((model_data.grid.X >= 0.5) & (model_data.grid.X < (0.5+dx)));
109 
110  % if xnumintervals even => this is exactly the middle point
111 
112  if mod(model.xnumintervals,2) == 0
113 
114  A_1((size(A_1,1)*(ind-1)+ind+1):end) = 0;
115  A_1(ind,ind) = (0.5-model_data.grid.X(ind-1)) /(dx^2);
116  A_1(ind-1,ind-1) = (0.5-model_data.grid.X(ind-2)) /(dx^2);
117  A_1(ind,ind-1) = -(0.5-model_data.grid.X(ind-1)) /(dx^2);
118  A_1(ind-1,ind) = A_1(ind,ind-1);
119 
120  A_2(1:(size(A_2,1)*(ind-2)+ind-2)) = 0;
121  A_2(ind,ind) = (model_data.grid.X(ind+1)-0.5) /(dx^2);
122  A_2(ind-1,ind-1) = (model_data.grid.X(ind)-0.5) /(dx^2);
123  A_2(ind,ind-1) = -(model_data.grid.X(ind)-0.5) /(dx^2);
124  A_2(ind-1,ind) = A_2(ind,ind-1);
125  else % if number of intervals odd : middle cell in both comp, * 0.5
126  error('to be implemented for odd numbers!');
127  end;
128 
129  if model.decomp_mode == 0
130  A = model.mu_1 * A_1 + val_fix * A_2;
131  f = -ones(H,1)*model_data.dx;
132 % f = -ones(H,1);
133  g = -model.obstacle(model_data.grid.X(2:end-1)',model);
134  else %model.decomp_mode = 1
135  A = {A_1, A_2};
136  f = {-ones(H,1)*model_data.dx};
137  gmin = model.obstacle(model_data.grid.X(2:end-1)',model);
138  g = {-gmin{1},-gmin{2}};
139  end;
140 
141  B = -eye(H);
142 
143 end;
144