Changeset 26572
- Timestamp:
- 11/09/21 07:04:19 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/contrib/defleurian/paraview/exportVTK.py
r25483 r26572 67 67 for solution in solnames: 68 68 #looking for multiple time steps 69 if (np.size(res_struct.__dict__[solution]) > num_of_timesteps): 70 num_of_timesteps = np.size(res_struct.__dict__[solution]) 71 num_of_timesteps = int(num_of_timesteps) 72 if 'Surface' in dict.keys(res_struct.__dict__[solution][0].__dict__): 73 moving_mesh = True 69 try: 70 if len(res_struct.__dict__[solution]) > num_of_timesteps: 71 num_of_timesteps = len(res_struct.__dict__[solution]) 72 num_of_timesteps = int(num_of_timesteps) 73 if 'Surface' in dict.keys(res_struct.__dict__[solution][0].__dict__): 74 moving_mesh = True 75 except TypeError: 76 continue 74 77 else: 75 78 num_of_timesteps = 1 … … 92 95 raise BadDimension('exportVTK does not support your element type') 93 96 97 #only keep the envelope and not the bulk of the results. 94 98 if enveloppe: 95 99 if dim == 3: … … 252 256 for sol in solnames: 253 257 treated_res = [] 254 #dealing with results on different timesteps 255 if(np.size(res_struct.__dict__[sol]) > timestep): 256 timestep = step 257 else: 258 timestep = np.size(res_struct.__dict__[sol]) 259 260 #getting the fields in the solution 261 if(type(res_struct.__dict__[sol]) == list): 258 #dealing with results on different timesteps 259 try: 260 if(len(res_struct.__dict__[sol]) > timestep): 261 timestep = step 262 else: 263 timestep = np.size(res_struct.__dict__[sol]) 264 except TypeError: 265 #result as no len() so no timesteps 266 timestep = 1 267 268 #getting the fields in the solution 269 if(type(res_struct.__dict__[sol]).__name__ == 'solution'): 262 270 spe_res_struct = res_struct.__dict__[sol].__getitem__(timestep) 263 271 fieldnames = dict.keys(spe_res_struct.__dict__) 264 el se:272 elif(type(res_struct.__dict__[sol]).__name__ == 'solutionstep'): 265 273 spe_res_struct = res_struct.__dict__[sol] 266 274 fieldnames = dict.keys(spe_res_struct.__dict__) 267 268 #Sorting scalars, vectors and tensors 275 elif(type(res_struct.__dict__[sol]).__name__ == 'results'): #this is a result without steps 276 spe_res_struct = res_struct.__dict__[sol] 277 fieldnames = dict.keys(spe_res_struct.__dict__) 278 else: 279 print("WARNING, solution type '{}' is not recognise, exported results might be wrong".format(type(res_struct.__dict__[sol]))) 280 spe_res_struct = res_struct.__dict__[sol] 281 fieldnames = dict.keys(spe_res_struct.__dict__) 282 283 #Sorting scalars, vectors and tensors 269 284 tensors = [field for field in fieldnames if field[-2:] in ['xx', 'yy', 'xy', 'zz', 'xz', 'yz']] 270 285 non_tensor = [field for field in fieldnames if field not in tensors] 271 286 vectors = [field for field in non_tensor if field[-1] in ['x', 'y', 'z'] and field[-4:] not in ['Flux']] 272 287 273 #check which field is a real result and print288 #check which field is a real result and print 274 289 for field in fieldnames: 290 print("Treating {}".format(field)) 275 291 if field in treated_res: 292 print("{} is already done".format(field)) 276 293 continue 277 294 elif field in vectors: 295 print("{} is a vector".format(field)) 278 296 try: 279 297 Vxstruct = np.squeeze(spe_res_struct.__dict__[field[:-1] + 'x']) … … 299 317 300 318 elif field in tensors: 319 print("{} is a tensor".format(field)) 301 320 try: 302 321 Txxstruct = np.squeeze(spe_res_struct.__dict__[field[:-2] + 'xx']) … … 346 365 else: 347 366 print("format for field {}.{} is not suported, field is skipped".format(sol, field)) 348 continue349 367 # }}} 350 368 # loop on arguments, if something other than result is asked, do it now {{{
Note:
See TracChangeset
for help on using the changeset viewer.