calculix / cae

CalculiX Advanced Environment is designed to guide you through the CalculiX keywords creation process and is aimed to help you reach the correct input file with no mistakes.
GNU General Public License v3.0
143 stars 34 forks source link

A small change to make ccx2paraview more comfortable to use. #35

Closed c7888026 closed 3 months ago

c7888026 commented 4 months ago

I notice that the ccx2paraview in the cae has two places which are not convenient to use:

  1. The vtu files are exported directly in current dictionary, more files mean more crowded.
  2. 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~

imirzov commented 3 months ago

Hi! Do you know, that you can create a pull request and became a contributor to this project? In this case I'll be able to merge your changes with only 1 click. Please, do the pull request.

c7888026 commented 3 months ago

Hi! Do you know, that you can create a pull request and became a contributor to this project? In this case I'll be able to merge your changes with only 1 click. Please, do the pull request.

Hi imirzov, I have created a pull request, could you please check if I have done it correctly? Thank you !

imirzov commented 3 months ago

Merged. Thank you!