1 function model = elastic_rope_model(params)
2 %
function model = elastic_rope_model(params)
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).
8 % params.xnumintervals: number of intervals, i.e. 200
for paper
10 % I.Maier, B. Haasdonk 30.05.2011
15 if ~isfield(params,
'xnumintervals');
16 params.xnumintervals = 202;
18 if ~isfield(params,
'xrange');
19 params.xrange = [0,1];
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]};
29 model.set_mu = @set_mu_default;
30 model.get_mu = @get_mu_default;
33 model.mu_1 = 21.7157/200;
35 model.mu_fix = 30/200;
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';
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;
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
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
69 model.enable_error_estimator = 0;
71 % parameter
for the snaphots computation
72 model.RB_numintervals = [4, 4];
74 % parameter
for making work with
new descr
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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));
86 function [A,B,f,g] = elastic_rope_operators(model,model_data)
87 %function [A,B,f,g] = elastic_rope_operators(model,model_data)
89 % provides offline/online decomposition
91 val_fix = model.mu_fix;
93 if model.decomp_mode == 2
94 A = [model.mu_1; val_fix];
97 g = model.obstacle([0,0],model);
102 H = model.xnumintervals -1;
104 A_2 = (-diag(ones(1,H-1),-1) + 2*eye(H) - diag(ones(1,H-1),1)) / ...
108 ind = find((model_data.grid.X >= 0.5) & (model_data.grid.X < (0.5+dx)));
110 % if xnumintervals even => this is exactly the middle point
112 if mod(model.xnumintervals,2) == 0
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);
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!');
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;
133 g = -model.obstacle(model_data.grid.X(2:end-1)',model);
134 else %model.decomp_mode = 1
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}};