rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
output_functional_boundary_integral.m
1 function s = output_functional_boundary_integral(model,model_data,u)
2 %function s = output_functional_boundary_integral(model,model_data,u)
3 %
4 % function computing an output functional from the
5 % function U. Grid is needed to have the space discretization
6 % information about U. A linear output function of the form of a
7 % boundary integral is computed:
8 %
9 % output(u) = int_{boundary(Omega)} f u dx
10 %
11 % required fields of model:
12 % output_function : pointer to function f,
13 % e.g. constant 1 or 1/boundary_length, etc.
14 % computing the weight function f of the integral
15 % output_integral_qdeg : degree of output integral computation
16 %
17 % u is assumed to be a function allowing a local evaluation
18 % u.evaluate(eindices, lcoord, grid,model)
19 
20 % Bernard Haasdonk 27.2.2011
21 
22 qdeg = model.output_integral_qdeg;
23 % find boundary edges and element indices
24 i = find(model_data.grid.NBI(:)<0)
25 [elind,edgeind] = ind2sub(size(model_data.grid.NBI),i);
26 % define integral kernel, here x is a 1-d coordinate in [0,1]
27 f = @(x) bnd_intkernel(x,elind,edgeind,model,model_data,u);
28 % compute output
29 res = intervalquadrature(qdeg,f);
30 s = sum(res);
31 
32 %%%%%%%%%%%%%%% auxiliary function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 % integral kernel for boundary integral
34 function res = bnd_intkernel(x,elind,edgeind,model,model_data,u)
35 res = [];
36 for local_edge_ind = 1:3;
37  % determine edgelengths for transformation formula
38  ind = find(edgeind==local_edge_ind);
39  EL = model_data.grid.EL(elind(ind),local_edge_ind);
40  lcoord = llocal2local(model_data.grid,local_edge_ind,x); % local coord for x on edge 1
41  glob = local2global(model_data.grid,elind(ind),lcoord);
42  uval = u.evaluate(elind(ind), lcoord, model_data.grid, model);
43  weightval = model.output_function(glob,model);
44  res = [res;uval.*weightval.*EL]
45 end;