gm_conductivity.m

来自「算断裂的」· M 代码 · 共 48 行

M
48
字号
function conducval = gm_conductivity(proc, userdata, points)
%% conducval = gm_conductivity(proc, userdata, points)
%% called by gmfem to evaluated conductivity function
%% see the documentation.
%% Last argument is a zba of coordinates.
%% Should return a zba.

proc = gm_strim(proc);
if proc(1) ~= '('
  error('conductivity procedure must start with a parenthesis')
end
if proc(length(proc)) ~= ')'
  error('Unbalanced parentheses in conductivity procedure');
end

proc(1) = ' ';
proc(length(proc)) = ' ';
proc = gm_strim(proc);
[first, rest] = strtok(proc);
first = gm_strim(first);
rest = gm_strim(rest);
[n,di] = size(points);
if strcmp(first, 'const')
  conducval = zba(str2num(rest) * ones(n,1));
elseif strcmp(first, 'vecformula') 
  formula = gm_percentsub(rest, 'double(points(:,', '))');
  conducval = zba(eval(formula));
elseif strcmp(first, 'formula')
  formula = gm_percentsub(rest, 'double(points(i,', '))');
  conducval = zba(-ones(n,1));
  for i = 0 : n - 1
    conducval(i) = eval(formula);
  end
else
  error('Unknown conductivity keyword');
end


% ------------------------------------------------------------------
% Copyright (c) 1998 by Cornell University.  All rights reserved.
% See the accompanying file 'Copyright' for authorship information,
% the terms of the license governing this software, and disclaimers
% concerning this software.
% ------------------------------------------------------------------
% This file is part of the QMG software.  
% Version 2.0 of QMG, release date RELDATE
% ------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?