rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
elastic_membrane_model.m
1 function model = elastic_membrane_model(params)
2 %function model = elastic_membrane_model(params)
3 %
4 % model of an elastic membrane in 2D above some obstacles
5 
6 % B. Haasdonk 11.3.2012
7 
8 if nargin < 1
9  params = [];
10 end;
11 
12 model.decomp_mode = 0;
13 model.name = 'elastic_membrane';
14 model.mu_names = {'mu_1','mu_2'}; % first: diffusivity, second: obstacle
15 model.mu_ranges = {[0.3,20],[0,1]};
16 
17 model.set_mu = @set_mu_default;
18 model.get_mu = @get_mu_default;
19 
20 % default mu-values
21 model.mu_1 = 20;
22 model.mu_2 = 0.5;
23 
24 % function pointers
25 model.gen_model_data = @vi_gen_model_data;
26 model.detailed_simulation = @vi_detailed_simulation;
27 
28 model.gen_detailed_data = @vi_gen_detailed_data;
29 model.get_inner_product_matrix = @(model,model_data) ...
30  model_data.df_info.regularized_h10_inner_product_matrix;
31 model.RB_stop_epsilon = 1e-6;
32 model.RB_stop_Nmax = 10;
33 model.gen_reduced_data = @vi_gen_reduced_data;
34 model.reduced_data_subset = @vi_reduced_data_subset;
35 model.rb_simulation = @vi_rb_simulation;
36 model.rb_reconstruction = @vi_rb_reconstruction;
37 
38 model.plot_sim_data = @vi_plot_sim_data;
39 model.plot_detailed_data = @vi_plot_detailed_data;
40 model.get_rb_size = @(model,detailed_data) size(detailed_data.RB_U,2);
41 model.get_dofs_from_sim_data = @(sim_data) sim_data.U;
42 model.is_stationary = 1;
43 model.gridtype = 'triagrid';
44 model.grid_initfile = 'unitcircle_coarse.mat';
45 
46 model.operators = @elastic_membrane_operators;
47 %model.get_inner_product_matrix = @standard_inner_product_matrix;
48 %model.get_supremizer_matrix = @elastic_membrane_supremizer_matrix;
49 
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 model.has_diffusivity = 1;
52 model.has_reaction = 0;
53 model.has_advection = 0;
54 model.has_source = 1;
55 %model.has_output_functional = 0;
56 model.has_dirichlet_values = 1;
57 model.has_neumann_values = 0;
58 model.has_robin_values = 0;
59 
60 % data functions
61 obstacle_coefficients = @(dummy,params) [0.5; params.mu_2];
62 obstacle_components = @(glob,params) ...
63  {exp(10*(-(glob(:,1)-0.5).^2 - (glob(:,2)-0.5).^2))-2, ...
64  exp(10*(-(glob(:,1)+0.5).^2 - (glob(:,2)).^2))};
65 model.obstacle = @(glob,params) ...
66  eval_affine_decomp_general(obstacle_components, ...
67  obstacle_coefficients,glob,params);
68 
69 % diffusion tensor: each row four entries a11,a_21,a_12,a_22.
70 % a11(x)=a22(x) = mu_i if x in block i, a12=a21 = 0.
71 mu_fix = 1;
72 my_diffusivity_tensor_coefficients = @(dummy,params) [mu_fix,params.mu_1];
73 model.diffusivity_tensor = @(glob,params) ...
74  eval_affine_decomp_general(...
75  @elastic_membrane_diffusivity_tensor_components, ...
76  my_diffusivity_tensor_coefficients, glob,params);
77 
78 dirichlet_values_coefficients = @(dummy,params) [0];
79 dirichlet_values_components = @(glob,params) {zeros(size(glob,1),1)};
80 model.dirichlet_values = @(glob,params) ...
81  eval_affine_decomp_general(dirichlet_values_components, ...
82  dirichlet_values_coefficients,glob,params);
83 
84 source_values_coefficients = @(dummy,params) [-2];
85 source_values_components = @(glob,params) {ones(size(glob,1),1)};
86 model.source = @(glob,params) ...
87  eval_affine_decomp_general(source_values_components, ...
88  source_values_coefficients,glob,params);
89 
90 % set pure dirichlet boundary conditions
91 model.boundary_type = @(glob,params) -ones(size(glob,1),1);
92 
93 %%% inf-sup, coercivity and continuity constant
94 %model.beta_b = 1;
95 %model.alpha_a = @(model) min(model.mu_1,30);
96 %model.gamma_a = @(model) max(model.mu_1,30);
97 % discretization parameter
98 %model.H = params.H;
99 model.enable_error_estimator = 0;
100 
101 model.beta_b = 1;
102 model.alpha_a = @(model) min(model.mu_1,mu_fix);
103 model.gamma_a = @(model) max(model.mu_1,mu_fix);
104 
105 % parameter for the snaphots computation
106 model.RB_numintervals = [4, 4];
107 model.RB_generation_mode = 'enrichment_by_supremizers';
108 model.w_u = 1;
109 model.w_lambda = 1;
110 
111 model.pdeg = 1; % polynomial degree 1
112 model.qdeg = 2; % quadrature degree
113 model.dimrange = 1;
114 
115 % parameter for making work with new descr
116 model.descr = [];
117 model.crb_enabled = 0;
118 model.verbose = 0;
119 model = elliptic_discrete_model(model);
120 
121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 % auxiliary functions
123 
124 function res = elastic_membrane_diffusivity_tensor_components(glob,params)
125 % diffusivity tensor component function:
126 % postivie x-direction and negative x-direction
127 res1 = zeros(size(glob,1),4);
128 i = find(glob(:,1)<=0);
129 if ~isempty(i)
130  res1(i,1) = 1 ;
131  res1(i,4) = 1 ;
132 end;
133 res2 = zeros(size(glob,1),4);
134 i = find(glob(:,1)>0);
135 if ~isempty(i)
136  res2(i,1) = 1;
137  res2(i,4) = 1;
138 end;
139 res = {res1,res2};
140 
141 function [A,B,f,g] = elastic_membrane_operators(model,model_data)
142 %function [A,B,f,g] = elastic_membrane_operators(model,model_data)
143 %
144 % provides offline/online decomposition
145 
146 [A,f] = fem_operators(model,model_data);
147 B = [];
148 
149 if model.decomp_mode == 2
150  % B = 1;
151  g = model.obstacle([],model);
152 elseif model.decomp_mode == 0
153  g = -model.obstacle([model_data.grid.X,model_data.grid.Y],model);
154  dirichlet_gids = model_data.df_info.dirichlet_gids;
155  B = -speye(model_data.df_info.ndofs);
156 % B(dirichlet_gids,dirichlet_gids) = 0;
157  g(dirichlet_gids) = 0;
158 else %model.decomp_mode = 1
159  gmin = model.obstacle([model_data.grid.X,model_data.grid.Y], ...
160  model);
161  dirichlet_gids = model_data.df_info.dirichlet_gids;
162  gmin{1}(dirichlet_gids) = 0;
163  gmin{2}(dirichlet_gids) = 0;
164  g = {-gmin{1},-gmin{2}};
165  dirichlet_gids = model_data.df_info.dirichlet_gids;
166  B = -speye(model_data.df_info.ndofs);
167 end;
168 
169 %function gamma_a = elastic_membrane_gamma_a(model);
function local_model = elliptic_discrete_model(model)
function creating a model with local functions out of a model with global functions. See detailed description for explanation.