Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/fastalgorithms/chunkie in…
Browse files Browse the repository at this point in the history
…to feature/issue-remove-chnkr-dot-h
  • Loading branch information
askhamwhat committed Apr 4, 2024
2 parents 1531d87 + 5331ce5 commit 8f87871
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 264 deletions.
3 changes: 3 additions & 0 deletions chunkie/@chunker/chunker.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@
p = chunkerpref(p);
end
k = p.k;
assert(k >= 2,'CHUNKER: order k of panels must be at least 2');
if nargin < 3
[obj.tstor,obj.wstor] = lege.exps(k);
else
assert(length(t)==k && length(w)==k,...
'CHUNKER: precomputed Legendre nodes appear to be wrong order');
obj.tstor = t;
obj.wstor = w;
end
Expand Down
2 changes: 1 addition & 1 deletion chunkie/@chunker/refine.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@

% split chunk i now, and recalculate nodes, d, etc
if (chnkr.nch + 1 > nchmax)
error('too many chunks')
error('CHUNKER.REFINE nchmax=%d exceeded during oversample',nchmax)
end

chnkr = split(chnkr,i,[],x,w,u,stype);
Expand Down
22 changes: 13 additions & 9 deletions chunkie/@kernel/kernel.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,21 @@
elseif ( isa(kern, 'function_handle') )
obj.eval = kern;
elseif ( isa(kern, 'kernel') )
if ( numel(kern) == 1 )
obj = kern;
else
% The input is a matrix of kernels.
% Create a single kernel object by interleaving the
% outputs of each sub-kernel's eval() and fmm() routines.
% TODO: Check that opdims are consistent
obj = interleave(kern);
if (numel(kern) == 1)
obj = kern;
else
obj = interleave(kern);
end
elseif isa(kern,'cell')
sz = size(kern); assert(length(sz)==2,'KERNEL: first input not of a supported type');
obj(sz(1),sz(2)) = kernel();
for j = 1:sz(2)
for i = 1:sz(1)
obj(i,j) = kernel(kern{i,j});
end
end
else
error('First input must be a string or function handle.');
error('KERNEL: first input not of a supported type');
end

end
Expand Down
16 changes: 8 additions & 8 deletions chunkie/chunkerfunc.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@
pref = chunkerpref(pref);
end

chnkr = chunker(pref); % empty chunker

ta = 0.0; tb = 2*pi; ifclosed=true;
chsmall = Inf; nover = 0;
eps = 1.0e-6;
lvlr = 'a'; maxchunklen = Inf; lvlrfac = 2.0;
lvlr = 'a'; maxchunklen = Inf; lvlrfac = 2;
nout = 1;

if isfield(cparams,'ta')
Expand Down Expand Up @@ -152,11 +153,11 @@
tsplits = sort(unique(tsplits),'ascend');
lab = length(tsplits);
if (lab-1 > nchmax)
error(['nchmax exceeded in chunkerfunc on initial splits.\n ',...
error(['CHUNKERFUNC: nchmax exceeded in chunkerfunc on initial splits.\n ',...
'try increasing nchmax in preference struct']);
end
if (any(tsplits > tb) || any(tsplits < ta))
error(['tsplits outside of interval of definition.\n', ...
error(['CHUNKERFUNC: tsplits outside of interval of definition.\n', ...
'check definition of splits, ta and tb']);
end

Expand Down Expand Up @@ -258,7 +259,7 @@
% . . . if here, not resolved
% divide - first update the adjacency list
if (nch +1 > nchmax)
error('too many chunks')
error('CHUNKERFUNC: nchmax=%d exceeded. Unable to resolve curve.',nchmax)
end

ifprocess(ich)=0;
Expand Down Expand Up @@ -366,7 +367,7 @@
% split chunk i now, and recalculate nodes, ders, etc

if (nch + 1 > nchmax)
error('too many chunks')
error('CHUNKERFUNC: nchmax=%d exceeded during level restriction (curve resolved).',nchmax);
end


Expand Down Expand Up @@ -436,7 +437,7 @@
fbkm1 = fbk;
bkm1 = bk;

for iter = 1:200
for iter = 1:52
m = (ak+bk)/2;
s = m;
if fbkm1 ~= fbk
Expand Down Expand Up @@ -486,7 +487,7 @@
end

if (nch + 1 > nchmax)
error('too many chunks')
error('CHUNKERFUNC: nchmax=%d exceeded while oversampling by nover=%d',nchmax,nover);
end

adjs(1,nch+1)=i;
Expand All @@ -507,7 +508,6 @@
% . . . finally evaluate the k nodes on each chunk, along with
% derivatives and chunk lengths

chnkr = chunker(pref); % empty chunker
chnkr = chnkr.addchunk(nch);


Expand Down
2 changes: 1 addition & 1 deletion chunkie/chunkerkernevalmat.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function mat = chunkerkernevalmat(chnkr,kern,targobj,opts)
function mat = chunkerkernevalmat(chnkr,kern,targobj,opts)
%CHUNKERKERNEVALMAT compute the matrix which maps density values on
% the chunk geometry to the value of the convolution of the given
% integral kernel with the density at the specified target points
Expand Down
57 changes: 20 additions & 37 deletions chunkie/chunkermat.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,33 +92,28 @@
% opts.sing provides a default value for singularities if not
% defined for kernels

if isa(kern,'function_handle')
kern2 = kernel(kern);
kern = kern2;
elseif isa(kern,'cell')
sz = size(kern);
kern2(sz(1),sz(2)) = kernel();
for j = 1:sz(2)
for i = 1:sz(1)
if isa(kern{i,j},'function_handle')
kern2(i,j) = kernel(kern{i,j});
elseif isa(kern{i,j},'kernel')
kern2(i,j) = kern{i,j};
else
msg = "Second input is not a kernel object, function handle, " ...
+ "or cell array";
error(msg);
end
end

% Flag for determining whether input object is a chunkergraph
icgrph = 0;

if (class(chnkobj) == "chunker")
chnkrs = chnkobj;
elseif(class(chnkobj) == "chunkgraph")
icgrph = 1;
chnkrs = chnkobj.echnks;
else
msg = "CHUNKERMAT: first input is not a chunker or chunkgraph object";
error(msg)
end

if ~isa(kern,'kernel')
try
kern = kernel(kern);
catch
error('CHUNKERMAT: second input kern not of supported type');
end
kern = kern2;

elseif ~isa(kern,'kernel')
msg = "Second input is not a kernel object, function handle, " ...
+ "or cell array";
error(msg);
end

if nargin < 3
opts = [];
end
Expand Down Expand Up @@ -167,18 +162,6 @@
adaptive_correction = opts.adaptive_correction;
end

% Flag for determining whether input object is a chunkergraph
icgrph = 0;

if (class(chnkobj) == "chunker")
chnkrs = chnkobj;
elseif(class(chnkobj) == "chunkgraph")
icgrph = 1;
chnkrs = chnkobj.echnks;
else
msg = "First input is not a chunker or chunkgraph object";
error(msg)
end

nchunkers = length(chnkrs);

Expand Down
3 changes: 2 additions & 1 deletion chunkie/demo/demo_barbell.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
% parameters for curve rounding/chunking routine to oversample boundary
cparams = [];
cparams.widths = 0.1*ones(size(verts,2),1);% width to cut about each corner
cparams.eps = 1e-6; % tolerance at which to resolve curve
cparams.eps = 1e-12; % tolerance at which to resolve curve
cparams.rounded = true;

% call smoothed-polygon chunking routine
% a smoothed version of edgevals is returned in
% chnkr.data

chnkr = chunkerpoly(verts,cparams,[],edgevals);
chnkr = chnkr.refine();

Expand Down
Loading

0 comments on commit 8f87871

Please sign in to comment.