1 function inner_product_matrices = comsol_thermal_block_calculate_inner_product_matrices(model,model_data)
2 %
function inner_product_matrices = comsol_thermal_block_calculate_inner_product_matrices(model,model_data)
4 % This
function computes the L2 and H1-inner-product-matrices
for the
5 % comsol_thermal_block_model. Since the model is a coefficient
for model,
6 % it sets the reaction coefficient a=1, all others to 0
for the L2-Matrix.
7 % For the H1-Matrix reaction and diffusion coefficients are set to 1, all
15 % - inner_product_matrices:
struct containing the L2- and H1-inner
16 % product matrices in full and eliminated version.
18 % Oliver Zeeb, 2013/11/21
21 comsol_model=model_data.comsol_model;
22 %
get all tags of the coefficient forms (so that
this file works with all
23 %thermal block models no matter which dimension they are
24 all_feature_tags = cellstr(
char(comsol_model.physics(
'c').feature.tags));
26 for k = 1:length(all_feature_tags)
27 feature_type =
char(comsol_model.physics('c').feature(all_feature_tags{k}).getType());
28 if strcmp(feature_type,
'CoefficientFormPDE')
30 cfeq_tag{nr_cfeq} = all_feature_tags{k};
35 warning(
'No CoefficientFormPDE found in the model!')
39 %get all original parameters
41 c_coeff{k} = cellstr(
char(comsol_model.physics(
'c').feature(cfeq_tag{k}).getStringMatrix(
'c')));
42 a_coeff{k} = cellstr(
char(comsol_model.physics(
'c').feature(cfeq_tag{k}).getStringMatrix(
'a')));
43 f_coeff{k} = cellstr(
char(comsol_model.physics(
'c').feature(cfeq_tag{k}).getStringMatrix(
'f')));
44 ea_coeff{k} = cellstr(
char(comsol_model.physics(
'c').feature(cfeq_tag{k}).getStringMatrix(
'ea')));
45 da_coeff{k} = cellstr(
char(comsol_model.physics(
'c').feature(cfeq_tag{k}).getStringMatrix(
'da')));
46 al_coeff{k} = cellstr(
char(comsol_model.physics(
'c').feature(cfeq_tag{k}).getStringMatrix(
'al')));
47 be_coeff{k} = cellstr(
char(comsol_model.physics(
'c').feature(cfeq_tag{k}).getStringMatrix(
'be')));
48 ga_coeff{k} = cellstr(
char(comsol_model.physics(
'c').feature(cfeq_tag{k}).getStringMatrix(
'ga')));
51 %reset the coefficients to a=1, all others=0
for all coefficient forms!--> L2-inner-product-matrix
53 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'c',
'0');
54 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'a',
'1');
55 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'f',
'0');
56 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'ea',
'0');
57 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'da',
'0');
58 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'al', {
'0' '0'});
59 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'be', {
'0' '0'});
60 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'ga', {
'0' '0'});
64 str = mphmatrix(comsol_model,
'sol1',
'Out',{
'K',
'Kc'});
65 inner_product_matrices.L2 = str.K;
66 inner_product_matrices.L2_eliminated = str.Kc;
68 %set c=a=1, all others 0 --> H1-inner-product-matrix
70 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'c', {
'1' '0' '0' '1'});
74 str = mphmatrix(comsol_model,
'sol1',
'Out',{
'K',
'Kc'});
75 inner_product_matrices.H1 = str.K;
76 inner_product_matrices.H1_eliminated = str.Kc;
79 %change back to original values:
81 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'c', c_coeff{k});
82 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'a', a_coeff{k});
83 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'f', f_coeff{k});
84 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'ea', ea_coeff{k});
85 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'da', da_coeff{k});
86 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'al', al_coeff{k});
87 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'be', be_coeff{k});
88 comsol_model.physics(
'c').feature(cfeq_tag{k}).set(
'ga', ga_coeff{k});