Skip to content
Browse files

Bugfix in mulgrid column_boundary_nodes(), to handle loops in the bou…

…ndary
  • Loading branch information...
1 parent 0703f0d commit 0bd3a806046826f375f426a3ab240a34570021a0 @acroucher committed Aug 7, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 mulgrids.py
View
14 mulgrids.py
@@ -1910,14 +1910,16 @@ def nodes_in_columns(self,columns):
def column_boundary_nodes(self,columns):
"""Returns an ordered list of the nodes on the outer boundary of the group of specified columns."""
nodes=self.nodes_in_columns(columns)
+ blacklist_connections=[]
def next_bdy_node(n):
for col in [c for c in n.column if c in columns]:
i=col.node.index(n)
n2=col.node[(i+1)%col.num_nodes]
con=self.connection_with_nodes([n,n2])
if not con: return n2
else:
- if not all([(c in columns) for c in con.column]): return n2
+ if not (con in blacklist_connections) and \
+ not all([(c in columns) for c in con.column]): return n2
return None
# look for a starting node along the left-hand edge of the selection (this avoids
# picking up any interior boundaries):
@@ -1937,6 +1939,16 @@ def next_bdy_node(n):
bdynodes.append(node)
node=next_bdy_node(node)
back=node.name==startnode.name
+ if (node in bdynodes) and not back : # loop in boundary
+ nodei=bdynodes.index(node)
+ nnodes=len(bdynodes)
+ loopcount=nnodes-nodei-1
+ for i in xrange(loopcount):
+ n1,n2=bdynodes[-2],bdynodes[-1]
+ con=self.connection_with_nodes([n1,n2])
+ if con: blacklist_connections.append(con)
+ bdynodes.pop()
+ node=bdynodes.pop()
return bdynodes
else: return []
def get_boundary_nodes(self): return self.column_boundary_nodes(self.columnlist)

0 comments on commit 0bd3a80

Please sign in to comment.
Something went wrong with that request. Please try again.