This file is indexed.

/usr/share/octave/packages/bim-1.1.5/bim1a_axisymmetric_advection_diffusion.m is in octave-bim 1.1.5-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
## Copyright (C) 2006-2014  Carlo de Falco, Massimiliano Culpo
##
## This file is part of:
##     BIM - Diffusion Advection Reaction PDE Solver
##
##  BIM is free software; you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation; either version 2 of the License, or
##  (at your option) any later version.
##
##  BIM is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with BIM; If not, see <http://www.gnu.org/licenses/>.
##
##  author: Carlo de Falco     <cdf _AT_ users.sourceforge.net>
##  author: Massimiliano Culpo <culpo _AT_ users.sourceforge.net>
##  author: Matteo Porro       <meoo85 _AT_ users.sourceforge.net>
##  author: Emanuela Abbate    <emanuela.abbate _AT_ mail.polimi.it>

## -*- texinfo -*-
##
## @deftypefn {Function File} @
## {[@var{A}]} = @
## bim1a_axisymmetric_advection_diffusion(@var{mesh},@var{alpha},@var{gamma},@var{eta},@var{beta})
##
## Build the Scharfetter-Gummel stabilized stiffness matrix for a
## diffusion-advection problem in cylindrical coordinates with axisymmetric 
## configuration. Rotational symmetry is assumed with respect to be the vertical
## axis r=0. Only grids that DO NOT contain r=0 are admissible.
##
##@example
##@group
##   |   |-------|   OK       |-------|   |   OK        |--|-----|   NO!
##  r=0                                  r=0              r=0
#@end group 
#@end example
## 
## The equation taken into account is:
##
## - 1/r * d/dr (@var{alpha} * @var{gamma} (@var{eta} du/dr - @var{beta} u)) = f
##
## where @var{alpha} is an element-wise constant scalar function,
## @var{eta} and @var{gamma} are piecewise linear conforming scalar
## functions, @var{beta} is an element-wise constant vector function.
##
## Instead of passing the vector field @var{beta} directly one can pass
## a piecewise linear conforming scalar function  @var{phi} as the last
## input.  In such case @var{beta} = grad @var{phi} is assumed.
##
## If @var{phi} is a single scalar value @var{beta} is assumed to be 0
## in the whole domain. 
##
## @seealso{bim1a_axisymmetric_rhs, bim1a_axisymmetric_reaction, 
## bim1a_axisymmetric_laplacian, bim2a_axisymmetric_advection_diffusion} 
## @end deftypefn

function A = bim1a_axisymmetric_advection_diffusion (x,alpha,gamma,eta,beta)

  ## Check input
  if nargin != 5
    error("bim1a_axisymmetric_advection_diffusion: wrong number of input parameters.");
  elseif !isvector(x)
    error("bim1a_axisymmetric_advection_diffusion: first argument is not a valid vector.");
  endif

  nnodes = length(x);
  nelem  = nnodes-1;

  ## Turn scalar input to a vector of appropriate size
  if isscalar(alpha)
    alpha = alpha*ones(nelem,1);
  endif
  if isscalar(gamma)
    gamma = gamma*ones(nnodes,1);
  endif
  if isscalar(eta)
    eta = eta*ones(nnodes,1);
  endif
  
  if !( isvector(alpha) && isvector(gamma) && isvector(eta) )
    error("bim1a_axisymmetric_advection_diffusion: coefficients are not valid vectors.");
  elseif (length(alpha) != nelem)
    error("bim1a_axisymmetric_advection_diffusion: length of alpha is not equal to the number of elements.");
  elseif (length(gamma) != nnodes)
    error("bim1a_axisymmetric_advection_diffusion: length of gamma is not equal to the number of nodes.");
  elseif (length(eta) != nnodes)
    error("bim1a_axisymmetric_advection_diffusion: length of eta is not equal to the number of nodes.");
  endif

  areak = reshape(diff(x),[],1);
  cm    = reshape((x(1:end-1)+x(2:end))/2,[],1);
  
  if (length(beta) == 1)
    vk = 0;
  elseif (length(beta) == nelem)
    vk = beta .* areak;
  elseif (length(beta) == nnodes)
    vk = diff(beta);
  else
    error("bim1a_axisymmetric_advection_diffusion: coefficient beta has wrong dimensions.");
  endif
  
  gammaetak = bimu_logm ( (gamma.*eta)(1:end-1), (gamma.*eta)(2:end));
  veta      = diff(eta);
  etak      = bimu_logm ( eta(1:end-1), eta(2:end));
  ck        = alpha .* gammaetak .* etak ./ areak .* abs(cm); 

  [bpk, bmk]  = bimu_bernoulli( (vk - veta)./etak);
 
  dm1 = [-(ck.*bmk); NaN]; 
  dp1 = [NaN; -(ck.*bpk)]; 
  d0  = [(ck(1).*bmk(1)); ((ck.*bmk)(2:end) + (ck.*bpk)(1:end-1)); (ck(end).*bpk(end))];
  A   = spdiags([dm1, d0, dp1],-1:1,nnodes,nnodes);

endfunction

%!test
%! n = 3;
%! mesh     = linspace(1,2,n+1)';
%! uex      = @(r) exp(r);
%! duexdr   = @(r) uex(r);
%! d2uexdr2 = @(r) uex(r);
%! Nnodes    = numel(mesh);
%! Nelements = Nnodes-1;
%! D = 1; v = 1;
%! alpha  = D*ones(Nelements,1);
%! gamma  = ones(Nnodes,1);
%! eta    = ones(Nnodes,1);
%! beta   = 1/D*v*ones(Nelements,1);
%! f = @(r) -D./r.*duexdr(r) - D.*d2uexdr2(r) ...
%!         + v./r .* uex(r) + v * duexdr(r);
%! rhs    = bim1a_axisymmetric_rhs(mesh, ones(Nelements,1), f(mesh));
%! S = bim1a_axisymmetric_advection_diffusion(mesh,alpha,gamma,eta,beta);
%! u = zeros(Nnodes,1); u([1,end]) = uex(mesh([1 end]));
%! u(2:end-1) = S(2:end-1,2:end-1)\(rhs(2:end-1) - S(2:end-1,[1 end])*u([1 end]));
%! assert(u,uex(mesh),1e-7)

%!test
%! n = 100;
%! mesh      = linspace(0,1,n+1)';
%! cm        = (mesh(1:end-1) + mesh(2:end))/2; 
%! uex       = @(r) - r.^2 + 1;
%! Nnodes    = numel(mesh);
%! Nelements = Nnodes-1;
%! D = 1;  v = 0;
%! alpha  = D*ones(Nelements,1);
%! gamma  = ones(Nnodes,1);
%! eta    = ones(Nnodes,1);
%! beta   = v;
%! f      = @(r) 4*D;
%! rhs    = bim1a_axisymmetric_rhs(mesh, ones(Nelements,1), f(mesh));
%! S = bim1a_axisymmetric_advection_diffusion(mesh,alpha,gamma,eta,beta);
%! u = zeros(Nnodes,1); u(end) = uex(mesh(end));
%! u(1:end-1) = S(1:end-1,1:end-1)\(rhs(1:end-1) - S(1:end-1,end)*u(end));
%! assert(u,uex(mesh),1e-3)

%!test
%! n = 100;
%! mesh      = linspace(0,1,n+1)';
%! cm        = (mesh(1:end-1) + mesh(2:end))/2; 
%! uex       = @(r) - r.^2 + 1;
%! Nnodes    = numel(mesh);
%! Nelements = Nnodes-1;
%! D = 1;  v = cm;
%! alpha  = D*ones(Nelements,1);
%! gamma  = ones(Nnodes,1);
%! eta    = ones(Nnodes,1);
%! beta   = 1/D*v;
%! f      = @(r) 4*D + 2 - 4*r.^2;
%! rhs    = bim1a_axisymmetric_rhs(mesh, ones(Nelements,1), f(mesh));
%! S = bim1a_axisymmetric_advection_diffusion(mesh,alpha,gamma,eta,beta);
%! u = zeros(Nnodes,1); u(end) = uex(mesh(end));
%! u(1:end-1) = S(1:end-1,1:end-1)\(rhs(1:end-1) - S(1:end-1,end)*u(end));
%! assert(u,uex(mesh),1e-3)

%!test
%! x = linspace(0,1,101);
%! A = bim1a_axisymmetric_advection_diffusion(x,1,1,1,0);
%! alpha = ones(100,1);
%! gamma = ones(101,1);
%! eta   = gamma;
%! B = bim1a_axisymmetric_advection_diffusion(x,alpha,gamma,eta,0);
%! assert(A,B)