rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fem_operators.m
1 function [A,r] = fem_operators(model,model_data)
2 %function [A,r] = fem_operators(model,model_data)
3 %
4 % function computing the matrix and rhs of an elliptic problem with
5 % finite element discretization
6 % supports affine decomposition, i.e. result
7 % depending on model.decomp_mode
8 
9 % B. Haasdonk 22.2.2011
10 
11 if model.decomp_mode == 2
12  df_info = []; % not required
13 else
14  df_info = model_data.df_info;
15 end;
16 
17 [r_source, r_dirichlet, r_neumann, r_robin] = ...
18  fem_rhs_parts_assembly(model,df_info);
19 
20 [A_diff , A_adv, A_reac, A_dirichlet, A_neumann, A_robin] = ...
21  fem_matrix_parts_assembly(model,df_info);
22 
23 
24 if model.decomp_mode == 0 % == complete: simple addition
25 
26  % assemble right hand side
27  r = r_source + r_neumann + r_robin + r_dirichlet;
28  if model.verbose > 5
29  disp('rhs assembled');
30  end;
31  % sparse system matrix:
32  A = spalloc(model_data.df_info.ndofs,model_data.df_info.ndofs,10); % rough upper bound for number of nonzeros
33  A = A_diff + A_adv + A_reac + A_neumann + A_robin + A_dirichlet;
34 
35  if model.verbose > 5
36  disp('matrix assembled');
37  end;
38 
39 elseif model.decomp_mode == 1 % == components: merge to cell arrays
40 
41  r = [r_source(:)', r_dirichlet(:)', r_neumann(:)', r_robin(:)'];
42 
43  A = [A_diff(:)' , A_adv(:)', A_reac(:)', ...
44  A_dirichlet(:)', A_neumann(:)', A_robin(:)'];
45 
46 % keyboard;
47 
48 else % decomp_mode == 2, coefficients: merge coeff vectors
49 
50  r = [r_source(:); r_dirichlet(:); r_neumann(:); r_robin(:)];
51 
52  A = [A_diff(:) ; A_adv(:); A_reac(:); ...
53  A_dirichlet(:); A_neumann(:); A_robin(:)];
54 
55 % keyboard;
56 
57 end;