rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
matrix_neumann.m
1 function res = matrix_neumann(x, model, df_info, i, j, elind, edgeind)
2 %function res = matrix_neumann(x, model, df_info, i ,j, elind, edgeind)
3 %
4 % auxiliary function for integral kernel for A_neumann
5 % integral kernel on all neumann-edges simultaneously
6 % here x is a scalar value on unit interval
7 % f(x) = (b^T n) hatphi_i hatphi_j
8 % multiplication with |edge| is realized in caller after quadrature.
9 % function can handle cell-array valued data
10 
11 % B. Haasdonk 22.2.2011
12 % IM 21.07.2016
13 
14 grid = df_info.grid;
15 res = zeros(0,1);
16 for local_edge_id = 1:3
17  % transform 1d coordinate to 2d local coordinate
18  lcoord = llocal2local(grid,local_edge_id,x); % local coord for x on edge 1
19  hat_phi_i = evaluate_basis_function(df_info,lcoord,i);
20  hat_phi_j = evaluate_basis_function(df_info,lcoord,j);
21  elinds = elind(edgeind==local_edge_id);
22  b = cache_function(@(xelind, xarg, xmodel)xmodel.velocity(grid, ...
23  xelind, xarg, xmodel), elinds, lcoord, model);
24  if ~iscell(b)
25  res = [res;...
26  ( b(:,1).*grid.NX(elinds,local_edge_id) ...
27  + b(:,2).*grid.NY(elinds,local_edge_id) ...
28  ) * hat_phi_i * hat_phi_j; ...
29  ];
30  else % iscell!!
31  if ~iscell(res)
32  res = cell(1,length(b));
33  for q = 1:length(b)
34  res{q} = zeros(0,1);
35  end;
36  end;
37  for q = 1:length(b)
38  res{q} = [res{q};...
39  ( b{q}(:,1).*grid.NX(elinds,local_edge_id) ...
40  + b{q}(:,2).*grid.NY(elinds,local_edge_id) ...
41  ) * hat_phi_i * hat_phi_j; ...
42  ];
43  end;
44 
45  end;
46 end;
function varargout = cache_function(func_ptr, varargin)
simple caching of function call inputs are cached too!