rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fem_rhs_boundary_part_assembly.m
1 function r_comp = fem_rhs_boundary_part_assembly(...
2  r_int_kernel,model,df_info,elind,edgeind,with_dirichlet_deletion)
3 %function r_comp = fem_rhs_boundary_part_assembly(...
4 % r_int_kernel,model,df_info,elind,edgeind,with_dirichlet_deletion);
5 %
6 % auxiliary function assembling the boundary integral components of
7 % system matrix A, i.e. Neumann and Robin components
8 %
9 % note: cell-array valued kernels can be integrated.
10 
11 % B. Haasdonk 22.2.2011
12 
13 r_comp = zeros(df_info.ndofs,1);
14 for i = 1:df_info.nlagrange_nodes
15  EL = [];
16  for local_edge_ind = 1:3;
17  ind = find(edgeind==local_edge_ind);
18  EL = [EL; df_info.grid.EL(elind(ind),local_edge_ind)];
19  end;
20  gids = df_info.global_dof_index(elind,i);
21  f = @(x) r_int_kernel(x,model,df_info,i,elind,edgeind);
22  res = intervalquadrature(model.qdeg,f);
23 
24  if ~iscell(res)
25  res = res .* EL; % due to transformation formula
26 
27  % here sparse matrix must be used to correclty handle multiple
28  % identical gids accumulatively!!!
29  r_comp_inc = sparse(gids,ones(length(gids),1),res,df_info.ndofs,1);
30  r_comp = r_comp + r_comp_inc;
31 
32  else % iscell!!
33  if ~iscell(r_comp)
34  % for first time: initialize r_comp
35  r_comp = cell(1,length(res));
36  for q=1:length(res)
37  r_comp{q} = zeros(df_info.ndofs,1);
38  end;
39  end;
40  for q = 1:length(res)
41  res{q} = res{q} .* EL; % due to transformation formula
42  r_comp_inc = sparse(gids,ones(length(gids),1),res{q},df_info.ndofs,1);
43  r_comp{q} = r_comp{q} + r_comp_inc;
44  end;
45  end;
46 end;
47 
48 if nargin<6
49  with_dirichlet_deletion = 1;
50 end;
51 
52 if with_dirichlet_deletion
53  if ~isempty(df_info.dirichlet_gids)
54  if ~iscell(r_comp)
55  r_comp(df_info.dirichlet_gids) = 0;
56  else
57  for q = 1:length(r_comp)
58  r_comp{q}(df_info.dirichlet_gids) = 0;
59  end;
60  end;
61  end;
62 end;
function res = intervalquadrature(poldeg, func, varargin)
integration of function func over reference interval == unit interval. by Gaussian quadrature exactly...