Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions chunkie/+chnk/+smoother/smooth.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
if isfield(opts,'nchs')
if (numel(opts.nchs) == 1)
nchs = opts.nchs*ones(nv,1);
elseif(size(opts.nchs,2) == nchs)
elseif(numel(opts.nchs) == nv)
nchs = opts.nchs;
end
end
Expand Down Expand Up @@ -132,7 +132,8 @@
return
end

chnkr = chunker.chunkerpoints(rt);
rt = reshape(rt,2,k,[]);
chnkr = chunkerpoints(rt);
if (nargout > 1)
varargout{1} = err;
end
Expand Down
3 changes: 0 additions & 3 deletions chunkie/@chunker/chunker.m
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,6 @@
kappa = signed_curvature(obj)
end
methods(Static)
obj = chunkerfunc(fcurve,varargin)
obj = chunkerpoly(verts,varargin)
obj = chunkerpoints(r,varargin)
function lvlrfac = lvlrfacdefault()
lvlrfac = 2.1;
end
Expand Down
114 changes: 114 additions & 0 deletions chunkie/chunkerpoints.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
function chnkr = chunkerpoints(src,opts)
%CHUNKERPOINTS create a chunker object given a set of Gauss-Legendre
% panels discretizing a curve.
%
% Syntax: chnkr = chunkerpoints(src,opts)
%
% Input:
% src - If src is of class 'double', then it should be a
% dim x k x nch array. dim is the dimension in which the curve
% lives (typically 2), k is the number of Gauss-Legendre nodes
% per panel (typically 16), and nch is the total number of panels.
% opts - a structure containing optional argumensts (defaults)
% opts.ifclosedtrue - a boolean. True if the desired curve
% is closed, and False if not. Note that no checking is done.
% All this changes is the corresponding chunker adjacency info.
%
% Output:
% chnkr - a chunker object containing the discretization of the domain
%
% see also CHUNKERPOLY, CHUNKERPREF, CHUNKER
%

d = [];
d2 = [];
if (strcmp(class(src),'double'))
r = src;
elseif (strcmp(class(src),'struct'))
if (isfield(src,'r'))
r = src.r;
else
error('ERROR: missing field r in chunkerpoints');
end
if (isfield(src,'d') && isequal(size(r),size(src.d)))
d = src.d;
end
if (isfield(src,'d2') && isequal(size(r),size(src.d)))
d2 = src.d2;
end
end

ifclosed = true;

if (nargin >1)
if (isfield(opts,'ifclosed'))
ifclosed = opts.ifclosed;
end

end

pref = [];

dim = size(r,1);
k = size(r,2);
nch = size(r,3);

pref.dim = dim;
pref.k = k;

[xs,~,us,vs] = lege.exps(k);
dermat = (vs*[lege.derpol(us); zeros(1,k)]).';


% . . . start chunking

adjs = zeros(2,nch);

adjs(1,:) = (1:nch) - 1;
adjs(2,:) = (1:nch) + 1;

if ifclosed
adjs(1,1)=nch;
adjs(2,nch)=1;
else
adjs(1,1)=-1;
adjs(2,nch)=-1;
end



% up to here, everything has been done in parameter space, [ta,tb]
% . . . finally evaluate the k nodes on each chunk, along with
% derivatives and chunk lengths

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


for i = 1:nch

rtmp = squeeze(r(:,:,i));
if (~isempty(d))
dtmp = squeeze(d(:,:,i));
else
dtmp = rtmp*dermat;
end
if (~isempty(d2))
d2tmp = squeeze(d2(:,:,i));
else
d2tmp = dtmp*dermat;
end
chnkr.rstor(:,:,i) = rtmp;
chnkr.dstor(:,:,i) = dtmp;
chnkr.d2stor(:,:,i) = d2tmp;
end

chnkr.adjstor(:,1:nch) = adjs(:,1:nch);

% Set normals
chnkr.nstor(:,:,1:nch) = normals(chnkr);

% Set weights
chnkr.wtsstor(:,1:nch) = weights(chnkr);

end
Loading