@@ -205,7 +205,10 @@ def _parse_session(self, title):
205205 elif level == 2 :
206206 if previous_line not in dict_session :
207207 dict_session [previous_line ] = {}
208- dict_session [previous_line ][tmp [0 ]] = tmp [1 ]
208+ try :
209+ dict_session [previous_line ][tmp [0 ]] = tmp [1 ]
210+ except TypeError :
211+ pass
209212 if level == 0 :
210213 break
211214 previous_line = line
@@ -214,10 +217,26 @@ def _parse_session(self, title):
214217
215218 def _parse_data (self , boundary , datatype , precision = 15 ):
216219
220+ import sys
217221 if boundary is not None :
218222 boun = str .encode (boundary )
219- if b"value" in self .content .split (boun )[1 ].split (b"}" )[0 ]:
220- data = self .content .split (boun )[1 ].split (b"value" )[1 ]
223+ if (np .size (self .content .split (boun ))<= 2 ):
224+ iboun = 1
225+ else :
226+ lines = self .content .split (b"\n " )
227+ iboun = 0
228+ for line in lines :
229+ if boun in line .strip ():
230+ iboun += 1
231+ if boun == line .strip ():
232+ break
233+
234+ if iboun >= np .size (self .content .split (boun )):
235+ print (R + "Error : No boundary/patch " + str (boun )+ W )
236+ sys .exit (1 )
237+
238+ elif b"value" in self .content .split (boun )[iboun ].split (b"}" )[0 ]:
239+ data = self .content .split (boun )[iboun ].split (b"value" )[1 ]
221240 else :
222241 if self .verbose :
223242 print (R + "Warning : No data on boundary/patch" )
@@ -511,8 +530,8 @@ def _parse_points(self, precision):
511530 continue
512531 break
513532 self .nb_pts = int (line )
514- data = self .content .split (line , 1 )[1 ]
515-
533+ data = self .content .split (b'}' , 1 )[1 ]
534+ data = data . split ( line , 1 )[ 1 ]
516535 self .type_data = self .header [b"class" ]
517536
518537 if not self .is_ascii :
@@ -552,8 +571,21 @@ def _parse_owner(self):
552571 except ValueError :
553572 continue
554573 break
555- self .nb_faces = int (line )
556- data = self .content .split (line , 2 )[- 1 ]
574+ try :
575+ self .nb_faces = int (line )
576+ data = self .content .split (line , 2 )[- 1 ]
577+ # for mesh with number of cells <= 10
578+ except ValueError :
579+ for line in self .lines_stripped :
580+ try :
581+ line .split (b"(" )
582+ int (line .split (b"(" )[0 ])
583+ break
584+ except ValueError or TypeError :
585+ continue
586+ break
587+ self .nb_faces = int (line .split (b"(" )[0 ])
588+ data = b"\n (" + line .split (b"(" , 2 )[- 1 ]
557589
558590 self .type_data = self .header [b"class" ]
559591
0 commit comments