cae
cae copied to clipboard
A small change to make ccx2paraview more comfortable to use.
I notice that the ccx2paraview in the cae has two places which are not convenient to use:
- The vtu files are exported directly in current dictionary, more files mean more crowded.
- The button 'open vtu in paraview' cannot open '...vtu'
So I did some change in src/gui/job.py, here are the changes:
def export_vtu(self):
"""Convert FRD to VTU."""
from ccx2paraview import ccx2paraview
if os.path.isfile(self.frd):
ccx2paraview.Converter(self.frd, ['vtu']).run()
os.system('mkdir paraview') ### create dictionary
os.system('mv *.vtu paraview') ### move vtu files
os.system('mv *.pvd paraview') ### move pvd file
else:
logging.error('File not found:\n' \
+ self.frd \
+ '\nSubmit analysis first.')
def open_paraview(self):
"""Open VTU in ParaView."""
if os.path.isfile(s.path_paraview):
# Count result VTU files
file_list = []
for f in os.listdir(self.dir + '/paraview'): ### add path
f = os.path.basename(f)
if f.lower() == self.name[:-4] + '.vtu':
file_list = [f]
break
if f.lower().endswith('.vtu') and f.startswith(self.name[:-4]):
file_list.append(f)
if len(file_list) > 1:
#vtu_path = self.path + '...vtu'
f_name, f_extension = os.path.splitext(f) ### get file name
f_name, f_extension = os.path.splitext(f_name) ### get file name again
vtu_path = self.dir + '/paraview/' + f_name + '.pvd' ### point vtu_path to .pvd file
elif len(file_list) == 1:
vtu_path = self.path + '.vtu'
else:
logging.error('VTU file not found.\nExport VTU results first.')
return
command = [s.path_paraview, '--data=' + vtu_path]
logging.info(' '.join(command))
subprocess.Popen(command)
else:
logging.error('Wrong path to ParaView:\n' \
+ s.path_paraview \
+ '\nConfigure it in File->Settings.')
If there is any problem with my changes, please inform me anyway~