rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
comsol_thermal_block_operators.m
1 function [A, r] = comsol_thermal_block_operators(model,model_data)
2 %function [A, r] = comsol_thermal_block_operators(model,model_data)
3 %
4 % function returns the Operators of the comsol 2D thermal block model with
5 % affine decomposition!
6 %
7 % The Operators are extracted from COMSOL if model.use_comsol=1;
8 % Otherwise they are just forwarded from model_data where they are stored.
9 %
10 % Input:
11 % - model
12 % - model_data
13 %
14 % Output:
15 % - A, r: components (model.decomp_mode=1) or coefficients (model.decomp_mode=2)
16 % of the System A*u=r
17 %
18 % Oliver Zeeb, 25.08.2012
19 
20 
21 
22 switch model.decomp_mode
23  %%%%%%%%%%%%%%%%
24  case 0 % full matrices!
25  if model.use_comsol
26  cmodel = model_data.comsol_model;
27  cmodel.sol('sol1').feature('v1').set('scalemethod','none');
28  cmodel.sol('sol1').feature('s1').active(false);
29  str = mphmatrix(cmodel,'sol1','Out',{'K','L'});
30  A = str.K;
31  r = str.L;
32  cmodel.sol('sol1').feature('v1').set('scalemethod','auto');
33  cmodel.sol('sol1').feature('s1').active(true);
34  else %~model.use_comsol
35  error('not yet implemented (since this case is most times unneeded...)')
36  end
37 
38  %%%%%%%%%%%%%%%%
39  case 1 % components
40  if model.use_comsol
41  mu_old = get_mu(model);
42  cmodel = model_data.comsol_model;
43  cmodel.sol('sol1').feature('v1').set('scalemethod','none');
44  cmodel.sol('sol1').feature('s1').active(false);
45  A=cell(1,length(mu_old));
46  %extract the matrices
47  for k = 1:length(mu_old)
48  mu = zeros(length(mu_old),1);
49  mu(k) = 1;
50  model = set_mu(model,mu);
51  cmodel = comsol_set_mu_from_rbmatlab_model(model,cmodel);
52  str = mphmatrix(cmodel,'sol1','Out',{'K','L'});
53  A{k} = str.K;
54  if k==1
55  r{k} = str.L;
56  end
57  end
58  model=set_mu(model,mu_old);
59  cmodel = comsol_set_mu_from_rbmatlab_model(model,cmodel);
60  cmodel.sol('sol1').feature('v1').set('scalemethod','auto');
61  cmodel.sol('sol1').feature('s1').active(true);
62  if model.comsol_get_eliminated_data %cut the matrices --> return eliminated matrices!
63  for k=1:length(A)
64  A{k} = A{k}(model_data.ind_vectors.com_DOF_ind,model_data.ind_vectors.com_DOF_ind);
65  end
66  for k=1:length(r)
67  r{k} = r{k}(model_data.ind_vectors.com_DOF_ind);
68  end
69  end
70  else %decomp_mode = 1, ~model.use_comsol
71  if model.comsol_get_eliminated_data %return eliminated data
72  A = model_data.operators.A_comp_eliminated;
73  r = model_data.operators.f_comp_eliminated;
74  else %return full data
75  A = model_data.operators.A_comp_full;
76  r = model_data.operators.f_comp_full;
77  end
78  end
79 
80 
81  %%%%%%%%%%%%%%%%
82  case 2 %coefficients
83  A = get_mu(model);
84  r = 1;
85  otherwise
86  error('unknown decomp_mode')
87 end