rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
fem_matrix_volume_part_assembly.m
1 function A_comp = fem_matrix_volume_part_assembly(...
2  A_int_kernel,model,df_info);
3 %function A_comp = fem_matrix_volume_part_assembly(...
4 % A_int_kernel,model,df_info);
5 %
6 % auxiliary function assembling the volume integral components of
7 % system matrix A
8 % note: cell-array valued kernels can be integrated.
9 
10 % B. Haasdonk 29.1.2011
11 
12 A_comp = spalloc(df_info.ndofs,df_info.ndofs,1);
13 for i = 1:df_info.nlagrange_nodes
14  for j = 1:df_info.nlagrange_nodes
15  gids_i = df_info.global_dof_index(1:df_info.grid.nelements,i);
16  gids_j = df_info.global_dof_index(1:df_info.grid.nelements,j);
17  f = @(x) A_int_kernel(x,model,df_info,i,j);
18  res = triaquadrature(model.qdeg,f);
19  if ~iscell(res)
20  res = res .* df_info.detDF; % due to transformation formula
21  A_tmp = sparse(gids_i,gids_j,res,df_info.ndofs,df_info.ndofs);
22  A_comp = A_comp + A_tmp;
23  % if (A_tmp(6,11)~=0)
24  % A_tmp(6,11)
25  % end;
26  else % iscell!!!
27  if ~iscell(A_comp)
28  % for first time: initialize A_comp
29  A_comp = cell(1,length(res));
30  for q=1:length(res)
31  A_comp{q} = spalloc(df_info.ndofs,df_info.ndofs,1);
32  end;
33  end;
34  for q = 1:length(res)
35  res{q} = res{q} .* df_info.detDF; % due to transformation formula
36  A_tmp = sparse(gids_i,gids_j,res{q},df_info.ndofs,df_info.ndofs);
37  A_comp{q} = A_comp{q} + A_tmp;
38  end;
39  end;
40  end;
41 end;
42 
43 if ~isempty(df_info.dirichlet_gids)
44  if ~iscell(A_comp)
45  A_comp(df_info.dirichlet_gids,:) = 0;
46  A_comp(:,df_info.dirichlet_gids) = 0;
47  else
48  for q = 1:length(A_comp)
49  A_comp{q}(df_info.dirichlet_gids,:) = 0;
50  A_comp{q}(:,df_info.dirichlet_gids) = 0;
51  end;
52  end;
53 end;