Module SortFiles
@author: Alexandre Sac–Morane alexandre.sac-morane@enpc.fr
Sort the files generated during the simulation.
Expand source code
#-------------------------------------------------------------------------------
# Librairies
#-------------------------------------------------------------------------------
from pathlib import Path
import os
# Own
from main import index_to_str, index_to_str
#-------------------------------------------------------------------------------
# Functions
#-------------------------------------------------------------------------------
def Sort_vtk(dict_user):
'''
Determine the function called to sort files.
'''
if dict_user['reduce_vtk']:
Sort_vtk_reduced(dict_user)
else:
Sort_vtk_full(dict_user)
#-------------------------------------------------------------------------------
def Sort_vtk_full(dict_user):
'''
Sort .vtk files generated by MOOSE.
'''
L_ite_saved = []
j = 0
j_str = index_to_str(j)
filepath = Path('PF_Sintering_other_'+j_str+'.pvtu')
while filepath.exists():
L_ite_saved.append(j)
for i_proc in range(dict_user['n_proc']):
os.rename('PF_Sintering_other_'+j_str+'_'+str(i_proc)+'.vtu','output/vtk/PF_Sintering_other_'+j_str+'_'+str(i_proc)+'.vtu')
os.rename('PF_Sintering_other_'+j_str+'.pvtu','output/vtk/PF_Sintering_other_'+j_str+'.pvtu')
j = j + 1
j_str = index_to_str(j)
filepath = Path('PF_Sintering_other_'+j_str+'.pvtu')
# save the last iteration
dict_user['last_j_str'] = index_to_str(j-1)
dict_user['last_j'] = j-1
# saved the iterations used
dict_user['L_ite_saved'] = L_ite_saved
Functions
def Sort_vtk()-
Determine the function called to sort files.
Expand source code
def Sort_vtk(dict_user): ''' Determine the function called to sort files. ''' if dict_user['reduce_vtk']: Sort_vtk_reduced(dict_user) else: Sort_vtk_full(dict_user) def Sort_vtk_full()-
Sort .vtk files generated by MOOSE.
Expand source code
def Sort_vtk_full(dict_user): ''' Sort .vtk files generated by MOOSE. ''' L_ite_saved = [] j = 0 j_str = index_to_str(j) filepath = Path('PF_Sintering_other_'+j_str+'.pvtu') while filepath.exists(): L_ite_saved.append(j) for i_proc in range(dict_user['n_proc']): os.rename('PF_Sintering_other_'+j_str+'_'+str(i_proc)+'.vtu','output/vtk/PF_Sintering_other_'+j_str+'_'+str(i_proc)+'.vtu') os.rename('PF_Sintering_other_'+j_str+'.pvtu','output/vtk/PF_Sintering_other_'+j_str+'.pvtu') j = j + 1 j_str = index_to_str(j) filepath = Path('PF_Sintering_other_'+j_str+'.pvtu') # save the last iteration dict_user['last_j_str'] = index_to_str(j-1) dict_user['last_j'] = j-1 # saved the iterations used dict_user['L_ite_saved'] = L_ite_saved