From 00984db0fde36e26eeb3e5031eeb5780e97af950 Mon Sep 17 00:00:00 2001 From: Travis Askham Date: Sat, 19 Oct 2024 14:28:53 -0400 Subject: [PATCH] fixes bugs in interior and moves inregion to new method. fixes bug for nested regions that was not detected by earlier tests --- chunkie/chunkgraphinregion.m | 33 +++++++++++++++++++-------------- devtools/test/mixedbcTest.m | 9 ++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/chunkie/chunkgraphinregion.m b/chunkie/chunkgraphinregion.m index bce5060..943bf9c 100644 --- a/chunkie/chunkgraphinregion.m +++ b/chunkie/chunkgraphinregion.m @@ -77,9 +77,10 @@ end nr = numel(cg.regions); + for ir = 1:nr ncomp = numel(cg.regions{ir}); - intmp = zeros(npts,1); + chnkrscomp(ncomp) = chunker(p,t,w); for ic = 1:ncomp edgelist = cg.regions{ir}{ic}; nedge = numel(edgelist); @@ -87,23 +88,27 @@ for ie = 1:nedge eid = edgelist(ie); if eid > 0 - if ir == 1 - chnkrs(ie) = cg.echnks(eid); - else - chnkrs(ie) = reverse(cg.echnks(eid)); - end + chnkrs(ie) = cg.echnks(eid); else - if ir == 1 - chnkrs(ie) = reverse(cg.echnks(-eid)); - else - chnkrs(ie) = cg.echnks(-eid); - end + chnkrs(ie) = sort(reverse(cg.echnks(-eid))); end end - intmp = intmp + reshape(chunkerinterior(merge(chnkrs(1:nedge)),ptsobj,opts),npts,1); + nchs = [chnkrs(1:nedge).nch]; + ladr = cumsum([1, nchs(:).']); + chnkrtmp = merge(chnkrs(1:nedge)); + chnkrtmp.adj(1,1) = ladr(end)-1; + chnkrtmp.adj(2,end) = 1; + for jj = 1:(nedge-1) + ich1 = ladr(jj+1)-1; ich2 = ladr(jj+1); + chnkrtmp.adj(1,ich2) = ich1; + chnkrtmp.adj(2,ich1) = ich2; + end + if ir ~= 1 + chnkrtmp = reverse(chnkrtmp); + end + chnkrscomp(ic) = chnkrtmp; end - - intmp = intmp > 0; + intmp = reshape(chunkerinterior(merge(chnkrscomp(1:ncomp)),ptsobj,opts),npts,1); if ir == 1 ids(~intmp) = ir; else diff --git a/devtools/test/mixedbcTest.m b/devtools/test/mixedbcTest.m index 666bd30..84f9047 100644 --- a/devtools/test/mixedbcTest.m +++ b/devtools/test/mixedbcTest.m @@ -93,14 +93,9 @@ targets = zeros(2,length(xxtarg(:))); targets(1,:) = xxtarg(:); targets(2,:) = yytarg(:); -start = tic; in1 = chunkerinterior(merge(cgrph.echnks(edir)),{xtarg,ytarg}); -in2 = chunkerinterior(reverse(merge(cgrph.echnks(eneu))),{xtarg,ytarg}); -t1 = toc(start); -in = in1 & ~in2; -out = ~in; - ids= chunkgraphinregion(cgrph,{xtarg,ytarg}); -nnz(in-(ids==2)) +in = ids == 2; +in2 = ids == 3; fprintf('%5.2e s : time to find points in domain\n',t1)