@@ -351,12 +351,19 @@ def _read(self):
351
351
352
352
# --- Tables that can be detected based on the "Label" (second entry on line)
353
353
# NOTE: MJointID1, used by SubDyn and HydroDyn
354
- NUMTAB_FROM_LAB_DETECT = ['NumAlf' , 'F_X' , 'MemberCd1' , 'MJointID1' , 'NOutLoc' , 'NOutCnt' , 'PropD' ,'Diam' ,'Type' ,'LineType' ]
355
- NUMTAB_FROM_LAB_DIM_VAR = ['NumAlf' , 'NKInpSt' , 'NCoefMembers' , 'NMembers' , 'NMOutputs' , 'NMOutputs' , 'NPropSets' ,'NTypes' ,'NConnects' ,'NLines' ]
356
- NUMTAB_FROM_LAB_VARNAME = ['AFCoeff' , 'TMDspProp' , 'MemberProp' , 'Members' , 'MemberOuts' , 'MemberOuts' , 'SectionProp' ,'LineTypes' ,'ConnectionProp' ,'LineProp' ]
357
- NUMTAB_FROM_LAB_NHEADER = [2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ]
358
- NUMTAB_FROM_LAB_NOFFSET = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
359
- NUMTAB_FROM_LAB_TYPE = ['num' , 'num' , 'num' , 'mix' , 'num' , 'sdout' , 'num' ,'mix' ,'mix' ,'mix' ]
354
+ NUMTAB_FROM_LAB_DETECT = ['NumAlf' , 'F_X' , 'MemberCd1' , 'MJointID1' , 'NOutLoc' , 'NOutCnt' , 'PropD' ]
355
+ NUMTAB_FROM_LAB_DIM_VAR = ['NumAlf' , 'NKInpSt' , 'NCoefMembers' , 'NMembers' , 'NMOutputs' , 'NMOutputs' , 'NPropSets' ]
356
+ NUMTAB_FROM_LAB_VARNAME = ['AFCoeff' , 'TMDspProp' , 'MemberProp' , 'Members' , 'MemberOuts' , 'MemberOuts' , 'SectionProp' ]
357
+ NUMTAB_FROM_LAB_NHEADER = [2 , 2 , 2 , 2 , 2 , 2 , 2 ]
358
+ NUMTAB_FROM_LAB_NOFFSET = [0 , 0 , 0 , 0 , 0 , 0 , 0 ]
359
+ NUMTAB_FROM_LAB_TYPE = ['num' , 'num' , 'num' , 'mix' , 'num' , 'sdout' , 'num' ]
360
+ # MoorDyn Version 1 and 2 (with AUTO for LAB_DIM_VAR)
361
+ NUMTAB_FROM_LAB_DETECT += ['Diam' ,'Type' ,'LineType' , 'Attachment' ]
362
+ NUMTAB_FROM_LAB_DIM_VAR += ['NTypes:AUTO' ,'NConnects' ,'NLines:AUTO' , 'AUTO' ]
363
+ NUMTAB_FROM_LAB_VARNAME += ['LineTypes' ,'ConnectionProp' ,'LineProp' , 'Points' ]
364
+ NUMTAB_FROM_LAB_NHEADER += [ 2 , 2 , 2 , 2 ]
365
+ NUMTAB_FROM_LAB_NOFFSET += [ 0 , 0 , 0 , 0 ]
366
+ NUMTAB_FROM_LAB_TYPE += ['mix' ,'mix' ,'mix' , 'mix' ]
360
367
# SubDyn
361
368
NUMTAB_FROM_LAB_DETECT += ['GuyanDampSize' , 'YoungE' , 'YoungE' , 'EA' , 'MatDens' ]
362
369
NUMTAB_FROM_LAB_DIM_VAR += [6 , 'NPropSets' , 'NXPropSets' , 'NCablePropSets' , 'NRigidPropSets' ]
@@ -480,6 +487,19 @@ def _read(self):
480
487
i += 1 ;
481
488
self .readBeamDynProps (lines ,i )
482
489
return
490
+ elif line .upper ().find ('OUTPUTS' )> 0 :
491
+ if 'Points' in self .keys () and 'dtM' in self .keys ():
492
+ OutList ,i = parseFASTOutList (lines ,i + 1 )
493
+ d = getDict ()
494
+ d ['label' ] = 'Outlist'
495
+ d ['descr' ] = ''
496
+ d ['tabType' ] = TABTYPE_FIL # TODO
497
+ d ['value' ] = OutList
498
+ self .addComment ('------------------------ OUTPUTS --------------------------------------------' )
499
+ self .data .append (d )
500
+ self .addComment ('END' )
501
+ self .addComment ('------------------------- need this line --------------------------------------' )
502
+ return
483
503
484
504
# --- Parsing of standard lines: value(s) key comment
485
505
line = lines [i ]
@@ -597,7 +617,6 @@ def _read(self):
597
617
self .data .append (dd )
598
618
599
619
d ['label' ] = NUMTAB_FROM_LAB_VARNAME [ii ]
600
- d ['tabDimVar' ] = NUMTAB_FROM_LAB_DIM_VAR [ii ]
601
620
if d ['label' ].lower ()== 'afcoeff' :
602
621
d ['tabType' ] = TABTYPE_NUM_WITH_HEADERCOM
603
622
else :
@@ -607,10 +626,28 @@ def _read(self):
607
626
d ['tabType' ] = TABTYPE_NUM_SUBDYNOUT
608
627
else :
609
628
d ['tabType' ] = TABTYPE_MIX_WITH_HEADER
610
- if isinstance (d ['tabDimVar' ],int ):
629
+ # Finding table dimension (number of lines)
630
+ tabDimVar = NUMTAB_FROM_LAB_DIM_VAR [ii ]
631
+ if isinstance (tabDimVar , int ): # dimension hardcoded
632
+ d ['tabDimVar' ] = tabDimVar
611
633
nTabLines = d ['tabDimVar' ]
612
634
else :
613
- nTabLines = self [d ['tabDimVar' ]+ labOffset ]
635
+ # We either use a variable name or "AUTO" to find the number of rows
636
+ tabDimVars = tabDimVar .split (':' )
637
+ for tabDimVar in tabDimVars :
638
+ d ['tabDimVar' ] = tabDimVar
639
+ if tabDimVar == 'AUTO' :
640
+ # Determine table dimension automatically
641
+ nTabLines = findNumberOfTableLines (lines [i + nHeaders :], break_chars = ['---' ,'!' ,'#' ])
642
+ break
643
+ else :
644
+ try :
645
+ nTabLines = self [tabDimVar + labOffset ]
646
+ break
647
+ except KeyError :
648
+ #print('Cannot determine table dimension using {}'.format(tabDimVar))
649
+ # Hopefully this table has AUTO as well
650
+ pass
614
651
615
652
d ['label' ] += labOffset
616
653
#print('Reading table {} Dimension {} (based on {})'.format(d['label'],nTabLines,d['tabDimVar']));
@@ -755,10 +792,13 @@ def mat_tostring(M,fmt='24.16e'):
755
792
s += '\n ' .join ('\t ' .join ('{:15.8e}' .format (x ) for x in y ) for y in d ['value' ])
756
793
elif d ['tabType' ]== TABTYPE_FIL :
757
794
#f.write('{} {} {}\n'.format(d['value'][0],d['tabDetect'],d['descr']))
795
+ label = d ['label' ]
796
+ if 'kbot' in self .keys (): # Moordyn has no 'OutList' label..
797
+ label = ''
758
798
if len (d ['value' ])== 1 :
759
- s += '{} {} {}' .format (d ['value' ][0 ],d [ ' label' ], d ['descr' ]) # TODO?
799
+ s += '{} {} {}' .format (d ['value' ][0 ], label , d ['descr' ]) # TODO?
760
800
else :
761
- s += '{} {} {}\n ' .format (d ['value' ][0 ],d [ ' label' ], d ['descr' ]) # TODO?
801
+ s += '{} {} {}\n ' .format (d ['value' ][0 ], label , d ['descr' ]) # TODO?
762
802
s += '\n ' .join (fil for fil in d ['value' ][1 :])
763
803
elif d ['tabType' ]== TABTYPE_NUM_BEAMDYN :
764
804
# TODO use dedicated sub-class
@@ -1183,6 +1223,17 @@ def detectUnits(s,nRef):
1183
1223
return Units
1184
1224
1185
1225
1226
+ def findNumberOfTableLines (lines , break_chars ):
1227
+ """ Loop through lines until a one of the "break character is found"""
1228
+ for i , l in enumerate (lines ):
1229
+ for bc in break_chars :
1230
+ if l .startswith (bc ):
1231
+ return i
1232
+ # Not found
1233
+ print ('[FAIL] end of table not found' )
1234
+ return len (lines )
1235
+
1236
+
1186
1237
def parseFASTNumTable (filename ,lines ,n ,iStart ,nHeaders = 2 ,tableType = 'num' ,nOffset = 0 , varNumLines = '' ):
1187
1238
"""
1188
1239
First lines of data starts at: nHeaders+nOffset
0 commit comments