Skip to content

Commit 597a4b6

Browse files
committed
famodel_base updates to support parallel things in edges:
Subcomponents can now include parallel strings of subcomponents among the subcomponents of an edge, including at the ends. This gives support for things like bridles or double chain sections. The assemble function supports this by accepting a nested list of items, where nesting indicates multiple parallel edges or sequences of edges and nodes.
1 parent e225215 commit 597a4b6

File tree

3 files changed

+61
-9
lines changed

3 files changed

+61
-9
lines changed

famodel/famodel_base.py

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,11 @@ def addSubcomponents(self, items, iA=[0], iB=[-1]):
673673
# Store them as subcomponents of this edge
674674
self.subcomponents = items # dict(enumerate(items))
675675
for item in items:
676-
item.part_of = self
676+
if isinstance(item, list):
677+
for subitem in item:
678+
subitem.part_of = self
679+
else:
680+
item.part_of = self
677681

678682
# Assign ends
679683
self.subcons_A = list([items[0]]) # subcomponent for end A (can be multiple)
@@ -1089,10 +1093,42 @@ def assemble(items):
10891093

10901094
# >>> TODO: adjust this so it can connect parallel elements .eg. for bridles <<<
10911095

1096+
'''
1097+
# If the provided items isn't a list, there's nothing to assemble so return
1098+
if not isinstance(items[i], List):
1099+
print('Not a list - returning!')
1100+
return
1101+
'''
10921102
n = len(items)
10931103

10941104
for i in range(n-1):
1095-
if isinstance(items[i], Node) and isinstance(items[i+1], Edge):
1105+
1106+
if isinstance(items[i], list):
1107+
for subitem in items[i]: # go through each parallel subitem
1108+
1109+
if isinstance(subitem, list): # if it's a concatenation of multiple things
1110+
assemble(subitem) # make sure that any sublist is assembled
1111+
1112+
# attach the end objects of the subitem to the nodes before and after
1113+
if i > 0 and isinstance(items[i-1], Node): # attach to previous node
1114+
items[i-1].attach(subitem[0], end='a')
1115+
if i < n-1 and isinstance(items[i+1], Node): # attach to next node
1116+
items[i+1].attach(subitem[-1], end='b')
1117+
# note: this requires the end objects to be edges
1118+
1119+
elif isinstance(subitem, Edge): # if the subitem is just one edge
1120+
if i > 0 and isinstance(items[i-1], Node): # attach to previous node
1121+
items[i-1].attach(subitem, end='a')
1122+
if i < n-1 and isinstance(items[i+1], Node): # attach to next node
1123+
items[i+1].attach(subitem, end='b')
1124+
else:
1125+
raise Exception("Unsupported situation ... parallel subitems must be edges or concatenations")
1126+
1127+
elif isinstance(items[i], Node) and isinstance(items[i+1], list):
1128+
pass # this node connects to a bridle or doubled section,
1129+
# so it will be hooked up in the next step
1130+
1131+
elif isinstance(items[i], Node) and isinstance(items[i+1], Edge):
10961132
items[i].attach(items[i+1], end='a')
10971133

10981134
elif isinstance(items[i], Edge) and isinstance(items[i+1], Node):
@@ -1174,7 +1210,24 @@ def rotationMatrix(x3,x2,x1):
11741210

11751211
assemble([A, E, B])
11761212

1177-
E.addSubcomponents([e0,n0,e1,n1,e2])
1213+
E.addSubcomponents([e0,n0,e1,n1,e2])
1214+
1215+
1216+
# ----- a test for bridles etc -----
1217+
1218+
e0 = Edge(id='e0')
1219+
n0 = Node(id='n0')
1220+
e1 = Edge(id='e1')
1221+
n1 = Node(id='n1')
1222+
e2a = Edge(id='e2a')
1223+
e2b = Edge(id='e2b')
1224+
1225+
1226+
thelist = [e0, n0, e1, n1, [e2a, e2b]]
1227+
1228+
E = Edge(id='big edge')
1229+
1230+
E.addSubcomponents(thelist)
11781231

11791232
# ----- try joining two nodes -----
11801233

@@ -1184,7 +1237,7 @@ def rotationMatrix(x3,x2,x1):
11841237

11851238

11861239
# ----- tests connecting multi-level node and edge objects ----
1187-
'''
1240+
11881241
# --- Test 1 ---
11891242
# platform and fairlead
11901243
n1 = Node(id='n1')
@@ -1254,7 +1307,7 @@ def rotationMatrix(x3,x2,x1):
12541307
e1_n2.attach(e1_e1, end='B')
12551308
# attach mooring to platfrom (by lower objects, then upper will be automatic)
12561309
n2.attach(e1_n2)
1257-
'''
1310+
12581311
# --- Test 6 ---
12591312
# platform and fairlead
12601313
n1 = Node(id='n1')

famodel/mooring/mooring.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ def createSubsystem(self, case=0,pristine=True,dd=None, mooringSys=None):
483483
# save to modified ss (may have marine growth, corrosion, etc)
484484
self.ss_mod = ss
485485
return(self.ss_mod)
486-
486+
487+
487488
def mirror(self,create_subsystem=True):
488489
''' Mirrors a half design dictionary. Useful for symmetrical shared mooring lines where
489490
only half of the line is provided
@@ -1057,6 +1058,3 @@ def connectSubcomponents(self):
10571058
self.i_con = list(range(0, 2*self.n_sec+1, 2))
10581059
self.i_sec = list(range(1, 2*self.n_sec+1, 2))
10591060

1060-
1061-
1062-

famodel/platform/platform.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(self, id, r=[0,0,0], heading=0, mooring_headings=[60,180,300],rFair
6161
self.failure_probability = {}
6262
self.raftResults = {}
6363

64+
6465
def setPosition(self, r, heading=None, degrees=False,project=None):
6566
'''
6667
Set the position/orientation of the platform as well as the associated

0 commit comments

Comments
 (0)