rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
matrix_robin.m
1 function res = matrix_robin(x, model, df_info, i, j, elind, edgeind)
2 %function res = matrix_robin(x, model, df_info, i, j, elind, edgeind)
3 %
4 % auxiliary function for integral kernel for A_robin
5 % integral kernel on all robin-edges simultaneously
6 % here x is a scalar value on unit interval
7 % f(x) = (alpha/beta + b^T n) hatphi_i hatphi_j
8 % multiplication with |edge| is realized in caller after
9 % quadrature.
10 % This function can handle cell-array valued data
11 
12 % B. Haasdonk 22.2.2011
13 % IM 21.07.2016
14 
15 res = zeros(0,1);
16 grid = df_info.grid;
17 for local_edge_id = 1:3
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 
23  if model.decomp_mode == 0
24  res = [res; (model.robin_beta(grid,elinds,local_edge_id,x, ...
25  model).^(-1)) .* ...
26  model.robin_alpha(grid,elinds,local_edge_id,x, ...
27  model) * hat_phi_i * hat_phi_j ];
28  else
29  % number of components = 1
30  if ~iscell(res)
31  res = {zeros(0, 1)};
32  end
33 
34  res{1} = [res{1}; ...
35  ( (model.robin_beta(grid,elinds,local_edge_id,x, ...
36  model).^(-1)) .* ...
37  model.robin_alpha(grid,elinds,local_edge_id,x, ...
38  model) ...
39  ) * hat_phi_i * hat_phi_j ]; % local model!
40  end
41 
42  if model.has_advection
43  b = cache_function(@(xelind, xarg, xmodel)...
44  xmodel.velocity(grid, xelind, ...
45  xarg, xmodel), ...
46  elinds, lcoord, model);
47 
48  if ~iscell(b)
49  res(end-numel(elinds)+1:end) ...
50  = res(end-numel(elinds)+1:end) ...
51  + ( b(:,1) .* grid.NX(elinds,local_edge_id) ...
52  + b(:,2) .* grid.NY(elinds,local_edge_id) ...
53  ) * hat_phi_i * hat_phi_j; % local model!
54  else % iscell => components mode
55 
56  % number of components = 1+ Q_velocity y
57  if numel(res) < length(b)+1
58  res = [res, cell(1,length(b))];
59  for q = 1:length(b)
60  res{q+1} = zeros(0,1);
61  end
62  end
63 
64  for q = 1:length(b)
65  res{q+1} = [res{q+1};...
66  ( b{q}(:,1).*grid.NX(elinds,local_edge_id) ...
67  + b{q}(:,2).*grid.NY(elinds,local_edge_id) ...
68  ) * hat_phi_i * hat_phi_j; ...
69  ];
70  end
71  % keyboard;
72  end
73 
74  end %model.has_advection
75 end %local_edge_id
76 
77 end
function varargout = cache_function(func_ptr, varargin)
simple caching of function call inputs are cached too!