rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
thermalblock_dd_model.m
Go to the documentation of this file.
1 function model = thermalblock_dd_model(params)
2 %function model = thermalblock_dd_model(params)
3 % Custom thermalblock model used for domain decomposition
4 %
5 % Small model for the `\mu`-dependent PDE
6 %
7 % `- \nabla (k(x;\mu) \nabla u(x;\mu)) = h(x;\mu)`, in `\Omega`,
8 % `u(x;\mu) = 0`, on `\Gamma`.
9 %
10 % - `k(x;\mu)` is the block-wise constant heatcoefficient
11 % - `u(x;\mu)` is the solution
12 % - `h(x;\mu)` is the source function
13 
14 % I.Maier, 19.07.2011
15 
16 if nargin<1
17  params = [];
18 end;
19 
20 if ~isfield(params,'numintervals')
21  params.numintervals = 16;
22 end;
23 if ~isfield(params,'pdeg')
24  params.pdeg = 1;
25 end;
26 if ~isfield(params,'detailed_train_savepath')
27  params.detailed_train_savepath = '/dom_dec';
28 end;
29 
30 model = lin_stat_model_default;
31 model.decomp_mode = 0; % default
32 model.dual_mode = 0;
33 
34 % parameters:
35 model.mu_names = {'mu_1','mu_2','mu_3','mu_f'};
36 model.mu_ranges = {[0.1,10],[0.1,10],[0.1,10],[0,1]};
37 
38 model.RB_generation_mode = 'lagrangian';
39 model.detailed_train_savepath = params.detailed_train_savepath;
40 model.filecache_ignore_fields_in_model = {};
41 
42 model.RB_mu_list = {[0.1,0.1,0.1,1],[0.1,0.1,10,1],[0.1,10,0.1,1], ...
43  [0.1,10,10,1],[10,0.1,10,1],[10,10,0.1,1],[0.1, ...
44  5.05,5.05,0],[10,0.1,0.1,1],[0.1,5.05,10,1], ...
45  [10,0.1,10,0],[10,10,0.1,0],[5.05,0.1,0.1,1], ...
46  [0.1,10,5.05,1],[0.1,10,10,0],[5.05,10,10,1], ...
47  [10,0.1,5.05,1],[0.1,10,5.05,0],[10,0.1,0.1,0], ...
48  [0.1,0.1,10,0],[0.1,10,0.1,0],[10,5.05,0.1,1], ...
49  [5.05,0.1,5.05,1],[5.05,5.05,0.1,1],[10,5.05, ...
50  0.1,0],[5.05,10,10,0],[0.1,5.05,0.1,1]};
51 
52 % default parameter values:
53 model = set_mu(model,[1,1,1,0.35]);
54 
55 % data function specification:
56 model.has_diffusivity = 1;
57 model.has_advection = 0;
58 model.has_reaction = 0;
59 model.has_source = 1;
60 model.has_output_functional = 0;
61 model.has_dirichlet_values = 1;
62 model.has_neumann_values = 0;
63 model.has_robin_values = 0;
64 model.compute_output_functional = 1;
65 
66 % source:
67 model.gamma_1 = 20;
68 model.gamma_2 = 20;
69 source_coefficients = @(grid,eindices,loc,params) 80*[params.mu_f; ...
70  1-params.mu_f];
71 source_components = @my_source_components;
72 
73 model.source = @my_source_function;
74 model.source_function = @(grid,eindices,loc,params)...
75  eval_affine_decomp_general(source_components,source_coefficients,...
76  grid,eindices,loc,params);
77 
78 % diffusivity_tensor:
79 diffusivity_tensor_coefficients = @(grid,eincices,loc,params) ...
80  [params.mu_1; params.mu_2; params.mu_3; 1];
81 diffusivity_tensor_components = @my_diffusivity_tensor_components;
82 
83 model.diffusivity_tensor = @(grid,eindices,loc,params) ...
84  eval_affine_decomp_general(diffusivity_tensor_components, ...
85  diffusivity_tensor_coefficients, ...
86  grid,eindices,loc,params);
87 
89 dirichlet_coefficients = @(grid,eindices,face_index,lloc,params) 0;
90 dirichlet_components = @(grid,eindices,face_index,lloc,params) ...
91  { zeros(size(eindices,1),1) };
92 
93 model.dirichlet_values = @(grid,eindices,face_index,lloc,params) ...
94  eval_affine_decomp_general(dirichlet_components, ...
95  dirichlet_coefficients,grid, ...
96  eindices,face_index,lloc,params);
97 
98 % output function
99 output_coefficients = @(grid,eindices,loc,params) 16;
100 output_components = @(grid,eindices,loc,params) ...
101  { (grid.CX(eindices) < 0.25) & (grid.CY(eindices) > 0.75) };
102 
103 model.output_function = @(grid,eindices,loc,params) ...
104  eval_affine_decomp_general(output_components,output_coefficients, ...
105  grid,eindices,loc,params);
106 
107 model.operators_output = @fem_operators_output_volume_integral;
108 
109 % geometry settings:
110 model.gridtype = 'triagrid';
111 model.xnumintervals = params.numintervals;
112 model.ynumintervals = params.numintervals;
113 model.xrange = [0,1];
114 model.yrange = [0,1];
115 
116 % discretization parameters:
117 model.pdeg = params.pdeg;
118 model.qdeg = params.pdeg * 3;
119 model.dimrange = 1;
120 
121 % for error estimation:
122 model.coercivity_alpha = @my_coercivity_alpha;
123 model.continuity_gamma = @my_continuity_gamma;
124 
125 end
126 
127 %%%%%%%%%%%% auxiliary functions:
128 
129 function res = my_source_components(grid,eindices,loc,params)
130 glob = local2global(grid,eindices,loc,params);
131 res = { exp( -params.gamma_1 * ( (glob(:,1) - 0.5).^2 + ...
132  (glob(:,2) - 0.5).^2 ) ), ...
133  exp( -params.gamma_2 * ( (glob(:,1) - 0.875).^2 + ...
134  (glob(:,2) - 0.875).^2 ) ) };
135 end
136 
137 function res = my_source_function(grid,eindices,loc,params)
138 if params.dual_mode
139  res = params.output_function(grid,eindices,loc,params);
140  if ~iscell(res)
141  res = -res;
142  end
143 else
144  res = params.source_function(grid,eindices,loc,params);
145 end
146 end
147 
148 function res = my_diffusivity_tensor_components(grid,eindices,loc,params)
149 CX = grid.CX(eindices);
150 CY = grid.CY(eindices);
151 res = {[(CX<0.5) & (CY<0.5), zeros(length(CX),2), (CX<0.5) & (CY<0.5)], ...
152  [(CX>0.5) & (CY<0.5), zeros(length(CX),2), (CX>0.5) & (CY<0.5)], ...
153  [(CX<0.5) & (CY>0.5), zeros(length(CX),2), (CX<0.5) & (CY>0.5)], ...
154  [(CX>0.5) & (CY>0.5), zeros(length(CX),2), (CX>0.5) & (CY>0.5)] ...
155  };
156 end
157 
158 function res = my_coercivity_alpha(model)
159 mus = model.get_mu(model);
160 res = min([1;mus(1:end-1)]);
161 end
162 
163 function res = my_continuity_gamma(model)
164 mus = model.get_mu(model);
165 res = max([1;mus(1:end-1)]);
166 end
function Udirichlet = dirichlet_values(model, X, Y)
UDIRICHLET = DIRICHLET_VALUES([X],[Y], MODEL) Examples dirichlet_values([0,1,2],[1,1,1],struct(name_dirichlet_values, homogeneous, ... c_dir, 1)) dirichlet_values([0:0.1:1],[0],struct(name_dirichlet_values, xstripes, ... c_dir, [0 1 2], ... dir_borders, [0.3 0.6])) dirichlet_values([0:0.1:1],[0],struct(name_dirichlet_values, box, ... c_dir, 1, ... dir_box_xrange, [0.3 0.6], ... dir_box_yrange, [-0.1 0.1]))
function model = thermalblock_dd_model(params)
Custom thermalblock model used for domain decomposition.
function res = thermalblock(step, params)
thermalblock example
Definition: thermalblock.m:17