Skip to content

Commit

Permalink
pulling through targobj instead of targs in chunkie folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mrachh committed Nov 13, 2023
1 parent 6278df4 commit 4045dc9
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 102 deletions.
27 changes: 21 additions & 6 deletions chunkie/+chnk/+flam/kernbyindexr.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function mat = kernbyindexr(i,j,targs,chnkr,kern,opdims,spmat)
function mat = kernbyindexr(i,j,targobj,chnkr,kern,opdims,spmat)
%% evaluate system matrix by entry index utility function for
% general kernels, with replacement for specific entries and the
% ability to add a low-rank modification, rectangular version
Expand All @@ -17,6 +17,10 @@
%
% i - array of row indices to compute
% j - array of col indices to compute
% targobj - object describing the target points, can be specified as
% * array of points
% * chunker object
% * chunkgraph object
% chnkr - chunker object describing boundary
% whts - smooth integration weights on chnkr
% kern - kernel function of the form kern(s,t,stau,ttau) where s and t
Expand All @@ -42,15 +46,26 @@
[juni,~,ijuni] = unique(jpts);

% matrix-valued entries of kernel for unique points

ri = targs(:,iuni); rj = chnkr.r(:,juni);
rj = chnkr.r(:,juni);
dj = chnkr.d(:,juni); d2j = chnkr.d2(:,juni);
nj = chnkr.n(:,juni);
%di = bsxfun(@rdivide,di,sqrt(sum(di.^2,1)));
%dj = bsxfun(@rdivide,dj,sqrt(sum(dj.^2,1)));
srcinfo = []; srcinfo.r = rj; srcinfo.d = dj; srcinfo.d2 = d2j;
srcinfo.n = nj;
targinfo = []; targinfo.r = ri;
% Assign appropriate object to targinfo
targinfo = [];
if isa(targobj, "chunker")
targinfo.r = targobj.r(:,iuni);
targinfo.d = targobj.d(:,iuni);
targinfo.d2 = targobj.d2(:,iuni);
targinfo.n = targobj.n(:,iuni);
elseif isa(targobj, "chunkgraph")
targinfo.r = targobj.r(:,iuni);
targinfo.d = targobj.d(:,iuni);
targinfo.d2 = targobj.d2(:,iuni);
targinfo.n = targobj.n(:,iuni);
else
targinfo.r = targobj(:,iuni);
end

matuni = kern(srcinfo,targinfo);

Expand Down
50 changes: 34 additions & 16 deletions chunkie/chunkerinterior.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
function [in] = chunkerinterior(chnkr,pts,opts)
function [in] = chunkerinterior(chnkobj,ptsobj,opts)
%CHUNKERINTERIOR returns an array indicating whether each point specified
% % by pts is inside the domain. Assumes the domain is closed.
%
% Syntax: in = chunkerinterior(chnkr,pts,opts)
% in = chunkerinterior(chnkr,{x,y},opts) % meshgrid version
% Syntax: in = chunkerinterior(chnkobj,pts,opts)
% in = chunkerinterior(chnkobj,{x,y},opts) % meshgrid version
%
% Input:
% chnkr - chunker object describing geometry
% pts - (chnkr.dim,:) array of points to test
%
% {x,y} - length 2 cell array. the points checked then have the
% coordinates of a mesh grid [xx,yy] = meshgrid(x,y)
% chnkobj - chunker object or chunkgraph object describing geometry
% ptsobj - object describing the target points, can be specified as
% * (chnkr.dim,:) array of points to test
% * {x,y} - length 2 cell array. the points checked then have the
% coordinates of a mesh grid [xx,yy] = meshgrid(x,y)
% * chunker object, in which case it uses chunker.r(:,:)
% * chunkgraph object, in which case it uses chunkgraph.r(:,:)
%
% Optional input:
% opts - options structure with entries:
Expand All @@ -34,23 +36,39 @@

grid = false;

assert(chnkr.dim == 2,'interior only well-defined for 2D');

if nargin < 3
opts = [];
end

if isa(pts,"cell")
assert(length(pts)==2,'second input should be either 2xnpts array or length 2 cell array');
x = pts{1};
y = pts{2};
grid = true;
% Assign appropriate object to chnkr
if class(chnkobj) == "chunker"
chnkr = chnkobj;
elseif class(chnkobj) == "chunkgraph"
chnkr = merge(chnkobj.echnks);
else
msg = "Unsupported object in chunkerinteriort";
error(msg)
end

if grid
assert(chnkr.dim == 2,'interior only well-defined for 2D');

% Assign appropriate object to pts
if isa(ptsobj, "cell")
assert(length(ptsobj)==2,'second input should be either 2xnpts array or length 2 cell array');
x = ptsobj{1};
y = ptsobj{2};
grid = true;
[xx,yy] = meshgrid(x,y);
pts = [xx(:).'; yy(:).'];
end
elseif isa(ptsobj, "chunker")
pts = ptsobj.r(:,:);
elseif isa(ptsobj, "chunkgraph")
pts = ptsobj.r(:,:);
else
pts = ptsobj;
end


usefmm = true;
if isfield(opts,'fmm')
Expand Down
Loading

0 comments on commit 4045dc9

Please sign in to comment.