1 function init_rb = comsol_rb_init_data_basis(model,detailed_data)
2 %
function init_rb = comsol_rb_init_data_basis(model,detailed_data)
4 % This
function returns the initial basis
for reduced basis generation.
5 % When
using comsol,
this is solution after the first time step, i.e. the second solution vector!
6 % (due to homogenization of the problem the first solution-vector (without
7 % adding model_data.operators_init_values) is zero!)
8 % The parameter is set to the midpoint of the parameter domain.
15 % - init_rb : normalized solution vector at t=0
20 %sets initial data
for basis generation
21 if strcmp(model.type,
'stat') %stationary problem
23 mu_old = get_mu(model);
25 mu_init=zeros(size(mu));
26 for k=1:length(model.mu_ranges)
27 mu_init(k) = 0.5*(model.mu_ranges{k}(1) + model.mu_ranges{k}(2));
29 model = set_mu(model,mu_init);
30 cmodel=comsol_set_mu_from_rbmatlab_model(model,detailed_data.comsol_model);
31 cmodel.sol(model.comsol_tags.sol).runAll;
32 init_rb=mphgetu(cmodel);
33 %normalize the init basis vector:
34 inProd_matrix = model.get_inner_product_matrix(detailed_data);
35 norm_init_rb = sqrt(init_rb
' * inProd_matrix * init_rb);
36 init_rb = init_rb / norm_init_rb;
37 %reset mu in the model and cmodel
38 model=set_mu(model,mu_old);
39 cmodel=comsol_set_mu_from_rbmatlab_model(model,detailed_data.comsol_model);
41 mu_init=zeros(size(get_mu(model)));
42 for k=1:length(model.mu_ranges)
43 mu_init(k) = 0.5*(model.mu_ranges{k}(1) + model.mu_ranges{k}(2));
45 model = set_mu(model,mu_init);
46 sim_data = detailed_simulation(model,detailed_data);
48 inProd_matrix = model.get_inner_product_matrix(detailed_data);
49 norm_init_rb = sqrt(init_rb' * inProd_matrix * init_rb);
50 init_rb = init_rb / norm_init_rb;
52 elseif strcmp(model.type,
'evol') %evolution problem
54 mu_old = get_mu(model);
56 mu_init=zeros(size(mu));
57 for k=1:length(model.mu_ranges)
58 mu_init(k) = 0.5*(model.mu_ranges{k}(1) + model.mu_ranges{k}(2));
60 model = set_mu(model,mu_init);
61 cmodel=comsol_set_mu_from_rbmatlab_model(model,detailed_data.comsol_model);
62 cmodel.sol(
'sol1').run;
63 init_rb=mphgetu(detailed_data.comsol_model,
'solnum',1);
64 %normalize the init basis vector:
65 inProd_matrix = model.get_inner_product_matrix(detailed_data);
66 norm_init_rb = sqrt(init_rb
' * inProd_matrix * init_rb);
67 init_rb = init_rb / norm_init_rb;
68 %reset mu in the model and cmodel
69 model=set_mu(model,mu_old);
70 cmodel=comsol_set_mu_from_rbmatlab_model(model,detailed_data.comsol_model);
71 else %~model.use_comsol
73 mu_init=zeros(size(mu));
74 for k=1:length(model.mu_ranges)
75 mu_init(k) = 0.5*(model.mu_ranges{k}(1) + model.mu_ranges{k}(2));
77 model = set_mu(model,mu_init);
78 model.decomp_mode = 1;
79 [L_I_comp, ~, b_comp] = model.operators_ptr(model,detailed_data);
80 model.decomp_mode = 2;
81 [L_I_coeff, ~, b_coeff] = model.operators_ptr(model,detailed_data);
82 L_I = lincomb_sequence(L_I_comp, L_I_coeff);
83 b = lincomb_sequence(b_comp, b_coeff);
84 init_rb = detailed_data.ind_vectors.Null*(L_I \ b) ;
85 %normalize the init basis vector:
86 inProd_matrix = model.get_inner_product_matrix(detailed_data);
87 norm_init_rb = sqrt(init_rb' * inProd_matrix * init_rb);
88 init_rb = init_rb / norm_init_rb;
91 error(
'model type not known!')