rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fem_matrix_boundary_part_assembly.m
Go to the documentation of this file.
1 function A_comp = fem_matrix_boundary_part_assembly(...
2  A_int_kernel,model,df_info,elind,edgeind)
3 %function A_comp = fem_matrix_boundary_part_assembly(...
4 % A_int_kernel,model,df_info,elind,edgeind);
5 % auxiliary function assembling the boundary integral components of
6 % system matrix A
7 % note: cell-array valued kernels can be integrated.
8 
9 % B. Haasdonk 22.2.2011
10 
11 A_comp = spalloc(df_info.ndofs,df_info.ndofs,1);
12 for i = 1:df_info.nlagrange_nodes
13  for j = 1:df_info.nlagrange_nodes
14  f = @(x) A_int_kernel(x,model,df_info,i,j,elind,edgeind);
15  res = intervalquadrature(model.qdeg,f);
16  EL = [];
17  for local_edge_ind = 1:3;
18  ind = find(edgeind==local_edge_ind);
19  EL = [EL; df_info.grid.EL(elind(ind),local_edge_ind)];
20  end;
21  gids_i = df_info.global_dof_index(elind,i);
22  gids_j = df_info.global_dof_index(elind,j);
23 
24  if ~iscell(res)
25  res = res .* EL; % due to transformation formula
26  A_tmp = sparse(gids_i,gids_j,res,df_info.ndofs,df_info.ndofs);
27  A_comp = A_comp + A_tmp;
28  else % iscell!!!
29  if ~iscell(A_comp)
30  % for first time: initialize A_comp
31  A_comp = cell(1,length(res));
32  for q=1:length(res)
33  A_comp{q} = spalloc(df_info.ndofs,df_info.ndofs,1);
34  end;
35  end;
36  for q = 1:length(res)
37  res{q} = res{q} .* EL; % due to transformation formula
38  A_tmp = sparse(gids_i,gids_j,res{q},df_info.ndofs,df_info.ndofs);
39  A_comp{q} = A_comp{q} + A_tmp;
40  end;
41  end;
42  end;
43 end;
44 
45 if ~isempty(df_info.dirichlet_gids)
46  if ~iscell(res)
47  A_comp(df_info.dirichlet_gids,:) = 0;
48  else % iscell!
49  for q = 1:length(A_comp)
50  A_comp{q}(df_info.dirichlet_gids,:) = 0;
51  end;
52  end;
53 end;
function res = intervalquadrature(poldeg, func, varargin)
integration of function func over reference interval == unit interval. by Gaussian quadrature exactly...
function A_comp = fem_matrix_boundary_part_assembly(A_int_kernel, model, df_info, elind, edgeind)
auxiliary function assembling the boundary integral components of system matrix A note: cell-array va...