@@ -16,6 +16,7 @@ class BrokenFormatError(Exception): pass
16
16
TABTYPE_NUM_WITH_HEADERCOM = 2
17
17
TABTYPE_NUM_NO_HEADER = 4
18
18
TABTYPE_NUM_BEAMDYN = 5
19
+ TABTYPE_NUM_SUBDYNOUT = 7
19
20
TABTYPE_MIX_WITH_HEADER = 6
20
21
TABTYPE_FIL = 3
21
22
TABTYPE_FMT = 9999 # TODO
@@ -345,7 +346,7 @@ def _read(self):
345
346
NUMTAB_FROM_LAB_VARNAME = ['AFCoeff' , 'TMDspProp' , 'MemberProp' , 'Members' , 'MemberOuts' , 'MemberOuts' , 'SectionProp' ,'LineTypes' ,'ConnectionProp' ,'LineProp' ]
346
347
NUMTAB_FROM_LAB_NHEADER = [2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ]
347
348
NUMTAB_FROM_LAB_NOFFSET = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
348
- NUMTAB_FROM_LAB_TYPE = ['num' , 'num' , 'num' , 'mix' , 'num' , 'num' , 'num' ,'mix' ,'mix' ,'mix' ]
349
+ NUMTAB_FROM_LAB_TYPE = ['num' , 'num' , 'num' , 'mix' , 'num' , 'sdout' , 'num' ,'mix' ,'mix' ,'mix' ]
349
350
# SubDyn
350
351
NUMTAB_FROM_LAB_DETECT += ['GuyanDampSize' , 'YoungE' , 'YoungE' , 'EA' , 'MatDens' ]
351
352
NUMTAB_FROM_LAB_DIM_VAR += [6 , 'NPropSets' , 'NXPropSets' , 'NCablePropSets' , 'NRigidPropSets' ]
@@ -592,6 +593,8 @@ def _read(self):
592
593
else :
593
594
if tab_type == 'num' :
594
595
d ['tabType' ] = TABTYPE_NUM_WITH_HEADER
596
+ elif tab_type == 'sdout' :
597
+ d ['tabType' ] = TABTYPE_NUM_SUBDYNOUT
595
598
else :
596
599
d ['tabType' ] = TABTYPE_MIX_WITH_HEADER
597
600
if isinstance (d ['tabDimVar' ],int ):
@@ -679,6 +682,16 @@ def toStringVLD(val,lab,descr):
679
682
lab = '{:13s}' .format (lab )
680
683
return val + ' ' + lab + ' - ' + descr .strip ().strip ('-' ).strip ()+ '\n '
681
684
685
+ def toStringIntFloatStr (x ):
686
+ try :
687
+ if int (x )== x :
688
+ s = '{:15.0f}' .format (x )
689
+ else :
690
+ s = '{:15.8e}' .format (x )
691
+ except :
692
+ s = x
693
+ return s
694
+
682
695
def beamdyn_section_mat_tostring (x ,K ,M ):
683
696
def mat_tostring (M ,fmt = '24.16e' ):
684
697
return '\n ' .join ([' ' + ' ' .join (['{:24.16E}' .format (m ) for m in M [i ,:]]) for i in range (np .size (M ,1 ))])
@@ -725,7 +738,7 @@ def mat_tostring(M,fmt='24.16e'):
725
738
s += '{}' .format (' ' .join (['{:15s}' .format (s ) for s in d ['tabUnits' ]]))
726
739
if np .size (d ['value' ],0 ) > 0 :
727
740
s += '\n '
728
- s += '\n ' .join ('\t ' .join ('{}' . format (x ) for x in y ) for y in d ['value' ])
741
+ s += '\n ' .join ('\t ' .join (toStringIntFloatStr (x ) for x in y ) for y in d ['value' ])
729
742
elif d ['tabType' ]== TABTYPE_NUM_WITH_HEADERCOM :
730
743
s += '! {}\n ' .format (' ' .join (['{:15s}' .format (s ) for s in d ['tabColumnNames' ]]))
731
744
s += '! {}\n ' .format (' ' .join (['{:15s}' .format (s ) for s in d ['tabUnits' ]]))
@@ -748,6 +761,11 @@ def mat_tostring(M,fmt='24.16e'):
748
761
K = data ['K' ][i ]
749
762
M = data ['M' ][i ]
750
763
s += beamdyn_section_mat_tostring (x ,K ,M )
764
+ elif d ['tabType' ]== TABTYPE_NUM_SUBDYNOUT :
765
+ data = d ['value' ]
766
+ s += '{}\n ' .format (' ' .join (['{:15s}' .format (s ) for s in d ['tabColumnNames' ]]))
767
+ s += '{}\n ' .format (' ' .join (['{:15s}' .format (s ) for s in d ['tabUnits' ]]))
768
+ s += '\n ' .join ('\t ' .join ('{:15.0f}' .format (x ) for x in y ) for y in data )
751
769
else :
752
770
raise Exception ('Unknown table type for variable {}' .format (d ))
753
771
if i < len (self .data )- 1 :
@@ -1263,6 +1281,13 @@ def parseFASTNumTable(filename,lines,n,iStart,nHeaders=2,tableType='num',nOffset
1263
1281
# If all values are float, we convert to float
1264
1282
if all ([strIsFloat (x ) for x in Tab .ravel ()]):
1265
1283
Tab = Tab .astype (float )
1284
+ elif tableType == 'sdout' :
1285
+ header = lines [0 ]
1286
+ units = lines [1 ]
1287
+ Tab = []
1288
+ for i in range (nHeaders + nOffset ,n + nHeaders + nOffset ):
1289
+ l = cleanAfterChar (lines [i ].lower (),'!' )
1290
+ Tab .append ( np .array (l .split ()).astype (int ))
1266
1291
else :
1267
1292
raise Exception ('Unknown table type' )
1268
1293
0 commit comments