rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fem_operators_output_boundary_integral.m
1 function v = fem_operators_output_boundary_integral(model,model_data)
2 %function v = fem_operators_output_boundary_integral(model,model_data)
3 %
4 % function computing the output vectors of an elliptic problem with
5 % finite element discretization and output functional consisting of
6 % a weighted boundary integral
7 %
8 % `s(u) = \int_{\partial \Omega} f(x) u(x)`
9 %
10 % required fields of model:
11 % output_function: weight function `f`
12 % decomp_mode: decision about the mode to be performed
13 % components, coefficients or complete
14 
15 % B. Haasdonk 22.2.2011
16 
17 if model.decomp_mode == 2 % == 2 coefficients
18  v = model.output_function([],model);
19 else
20  % select all boundary elements for integration
21  i = find(model_data.grid.NBI(:)<0);
22  [elind,edgeind] = ind2sub(size(model_data.grid.NBI),i);
23  % turn off dirichlet deletion:
24  with_dirichlet_deletion = 0;
25  % assemble vectors
26  v = fem_rhs_boundary_part_assembly(...
27  @bnd_output_int_kernel,model,model_data.df_info,...
28  elind,edgeind,with_dirichlet_deletion);
29 end;
30 
31 %%%%%%%%%%%%%%%%%%%%% boundary integral kernel
32 function res = bnd_output_int_kernel(x,model,df_info,i,elind,edgeind)
33 % here x is a scalar value on unit interval
34 % f(x) = output_function * hatphi_i
35 % multiplication with |edge| is realized in caller after quadrature.
36 % function can handle cell-array valued data
37 % this function is 99% identical to fem_rhs_neumann_integral_kernel
38 % perhaps merge sometime.
39 res = zeros(0,1);
40 for local_edge_id = 1:3
41  lcoord = llocal2local(...
42  df_info.grid,local_edge_id,x); % local coord for x on edge 1
43  hat_phi_i = fem_evaluate_basis_function(df_info,lcoord,i);
44  inds = find(edgeind==local_edge_id);
45  glob = local2global(df_info.grid,elind(inds),lcoord);
46  w = model.output_function(glob,model);
47  if ~iscell(w)
48  res = [res;...
49  w * hat_phi_i; ...
50  ];
51  else
52  if ~iscell(res)
53  res = cell(1,length(w));
54  for q = 1:length(w)
55  res{q} = zeros(0,1);
56  end;
57  end;
58  for q = 1:length(w)
59  res{q} = [res{q};...
60  w{q} * hat_phi_i; ...
61  ];
62  end;
63  end;
64 end;
65