Commit 56bb03f9 authored by sfritschi's avatar sfritschi
Browse files

Fixed bug where candidate has no throats left if targetsize contains 1

parent 0a88711d
......@@ -15,7 +15,7 @@ def main():
print("Min. number of throats per pore: %d" % min(pore_throat_counts))
print("Avg. number of throats per pore: %f" % (sum(pore_throat_counts) / len(pore_throat_counts)))
target = [3, 3, 3]
target = [2, 1, 2]
print("Target size: {}".format(target))
cutoff = 0.5 * max([basenet.ub[i] - basenet.lb[i] \
for i in range(len(basenet.ub))])
......
......@@ -191,7 +191,7 @@ class CellList:
# Retrieve payload from in-queue
payload = in_q.get()
if payload is None:
break # Terminate daemonic process
break # Terminate process
poreIdx = payload[0]
neighbors = payload[1]
......@@ -704,6 +704,10 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
n = len(pores)
copies = __add_buffer_layers(pores, L, basenet.Lmax)
# Flag for handling the case where original nbor pore and its periodic
# copies are potential candidates of a given pore at the same time
# (necessary only if target size is 1 in at least one dimension)
isPeriodicCheck = 1 in targetsize
# Domain size including periodic buffer layers on all sides
trueDomainSize = [L[i] + 2 * basenet.Lmax for i in range(d)]
# Initialize cell-list; Place each pore in respective cell-set
......@@ -715,7 +719,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
k = 0 # count of unrealised throats
nthreads = 4
# Spawn daemonic worker threads
# Spawn worker threads
in_q = mp.SimpleQueue()
out_q = mp.SimpleQueue()
......@@ -763,8 +767,6 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
count += 1
lt = ltc
# Remove nbor from candidates
del candidates[nborIdx]
nborc = nbor # memorize potential periodic copy
# find original of buffer layer pore
if (nbor.label != LABELS[0]):
......@@ -773,6 +775,18 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
else:
lbl = LABELS[0]
# Remove nbor from candidates as well as all periodic copies
del candidates[nborc.index]
# Remove original non-periodic nbor as well as all its
# periodic copies. Only applies if targetsize[i] = 1 for some i
if isPeriodicCheck:
if nbor.index in candidates:
del candidates[nbor.index]
for cpore in copies[nbor]:
if cpore.index in candidates:
del candidates[cpore.index]
# connect pore to nbor
throats.append([pore, nbor, lbl, throat.r])
# remove most similar throat of nbor
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment