def on_dsph_sim_finished(exit_code): """ Simulation finish handler. Defines what happens when the process finishes.""" # Reads output and completes the progress bar output = str(process.readAllStandardOutput().data(), encoding='utf-8') run_dialog.set_detail_text(str(output)) run_dialog.run_complete() run_fs_watcher.removePath(Case.the().path + "/" + Case.the().name + "_out/") if exit_code == 0: # Simulation went correctly Case.the().info.is_simulation_done = True Case.the().info.needs_to_run_gencase = False self.simulation_complete.emit(True) else: # In case of an error Case.the().info.needs_to_run_gencase = True if "exception" in str(output).lower(): log("There was an error on the execution. Opening an error dialog for that.") run_dialog.hide() self.simulation_complete.emit(False) error_dialog(__("An error occurred during execution. Make sure that parameters exist and are properly defined. " "You can also check your execution device (update the driver of your GPU). Read the details for more information."), str(output)) save_case(Case.the().path, Case.the())
def on_save_case(self, save_as=None): """ Defines what happens when save case button is clicked. Saves a freecad scene definition, and a dump of dsph data for the case.""" if Case.the().was_not_saved() or save_as: save_name, _ = QtGui.QFileDialog.getSaveFileName( self, __("Save Case"), Case.the().info.last_used_directory) Case.the().info.update_last_used_directory(save_name) else: save_name = Case.the().path if not save_name: return Case.the().info.needs_to_run_gencase = True save_case(save_name, Case.the()) save_current_freecad_document(Case.the().path) if Case.the().has_materials() and Case.the( ).execution_parameters.rigidalgorithm not in (2, 3): warning_dialog( __("Properties and Material information wasn't written. See details for more info." ), __("The case being saved has some properties/materials defined in one of its MKs.\n" "However, the solid-solid interaction on the execution parameters must be set to DEM or CHRONO for this feature to work." )) self.need_refresh.emit()
def on_apply_button(self): Case.the( ).custom.lsparam.eps = self.execution_options_tab.eps_coefficient.text( ) Case.the( ).custom.lsparam.deltasph = self.execution_options_tab.deltasph_coefficient.text( ) for current_phase in range(self.fluid_phases_num): current_phase_dict = Case.the( ).custom.lsparam.tabs_list[current_phase] Case.the( ).custom.lsparam.tabs_list[current_phase]['phase_type'] = str( self.phases_parameters_tab_list[current_phase].phase_type. currentIndex()) Case.the().custom.lsparam.tabs_list[current_phase][ 'mk'] = self.fluids[current_phase] Case.the().custom.lsparam.tabs_list[current_phase][ 'rhop'] = self.phases_parameters_tab_list[ current_phase].phase_rhop.text() Case.the().custom.lsparam.tabs_list[current_phase][ 'csound'] = self.phases_parameters_tab_list[ current_phase].phase_csound.text() Case.the().custom.lsparam.tabs_list[current_phase][ 'gamma'] = self.phases_parameters_tab_list[ current_phase].phase_gamma.text() Case.the().custom.lsparam.tabs_list[current_phase][ 'visco'] = self.phases_parameters_tab_list[ current_phase].phase_visco.text() Case.the().custom.lsparam.tabs_list[current_phase][ 'HBP_n'] = self.phases_parameters_tab_list[ current_phase].phase_HBP_n.text() Case.the().custom.lsparam.tabs_list[current_phase][ 'HBP_m'] = self.phases_parameters_tab_list[ current_phase].phase_HBP_m.text() Case.the().custom.lsparam.tabs_list[current_phase][ 'c'] = self.phases_parameters_tab_list[ current_phase].phase_c.text() Case.the().custom.lsparam.tabs_list[current_phase][ 'phi'] = self.phases_parameters_tab_list[ current_phase].phase_phi.text() Case.the().custom.lsparam.tabs_list[current_phase][ 'tau_yield'] = self.phases_parameters_tab_list[ current_phase].phase_tau_yield.text() file_tools.save_case(Case.the().path, Case.the()) Case.the().info.liquidsediment_phase_list_exists = True self.close()
def on_cfces_export(self): """ Export button behaviour.""" Case.the( ).custom.cfces_additional_parameters = self.cfces_additional_parameters_text.text( ) Case.the().custom.moment_mk = self.cfces_onlyprocess_text.text() Case.the().custom.moment_checked = self.moment_group_box.isChecked() Case.the().custom.moment_x1 = self.moment_x1_line_edit.text() Case.the().custom.moment_x2 = self.moment_x2_line_edit.text() Case.the().custom.moment_y1 = self.moment_y1_line_edit.text() Case.the().custom.moment_y2 = self.moment_y2_line_edit.text() Case.the().custom.moment_z1 = self.moment_z1_line_edit.text() Case.the().custom.moment_z2 = self.moment_z2_line_edit.text() Case.the().custom.cfces_plot = self.cfces_plot.isChecked() file_tools.save_case(Case.the().path, Case.the()) export_parameters = dict() export_parameters["save_mode"] = self.outformat_combobox.currentIndex() if "mk" in self.cfces_onlyprocess_selector.currentText().lower(): export_parameters["onlyprocess_tag"] = "-onlymk:" elif "id" in self.cfces_onlyprocess_selector.currentText().lower(): export_parameters["onlyprocess_tag"] = "-onlyid:" elif "position" in self.cfces_onlyprocess_selector.currentText().lower( ): export_parameters["onlyprocess_tag"] = "-onlypos:" export_parameters["onlyprocess"] = self.cfces_onlyprocess_text.text() export_parameters["filename"] = self.cfces_filename_text.text() #export_parameters["additional_parameters"] = '-filexml ' + Case.the().get_out_xml_file_path() + '.xml ' + self.cfces_additional_parameters_text.text() export_parameters[ "additional_parameters"] = self.cfces_additional_parameters_text.text( ) if self.moment_group_box.isChecked(): export_parameters[ "additional_parameters"] += " -momentaxis:{x1}:{y1}:{z1}:{x2}:{y2}:{z2}".format( x1=Case.the().custom.moment_x1, y1=Case.the().custom.moment_y1, z1=Case.the().custom.moment_z1, x2=Case.the().custom.moment_x2, y2=Case.the().custom.moment_y2, z2=Case.the().custom.moment_z2) computeforces_export(export_parameters, Case.the(), self.post_processing_widget) self.accept()
def on_boundvtk_export(self): """ Export button behaviour.""" n = 0 for obj in self.bound_obj_list: self.bound_obj_dicts[n]['mode'] = str(obj.only_mode.currentIndex()) self.bound_obj_dicts[n]['value'] = obj.only_value.text() self.bound_obj_dicts[n]['name'] = obj.file_name.text() n += 1 Case.the().custom.bound_obj_dicts = self.bound_obj_dicts file_tools.save_case(Case.the().path, Case.the()) self.accept() for obj in self.bound_obj_dicts: boundaryvtk_export(obj, self.post_processing_widget, Case.the())
def on_export_button(self): obj = {} obj["step"] = self.mksmixing_step.text() obj["init"] = self.mksmixing_init.text() obj["mk"] = str( int(self.fluid_mks[self.mksmixing_tracing.currentIndex()]) + 1) obj["dp"] = str(Case.the().dp) obj["cdp"] = self.mksmixing_cdp.text() obj["tout"] = str(Case.the().execution_parameters.timeout) obj["n1"] = self.mksmixing_n1.text() obj["n2"] = self.mksmixing_n2.text() obj["n3"] = self.mksmixing_n3.text() obj["calc"] = str(self.mksmixing_calc.currentIndex()) obj["vtk"] = self.mksmixing_vtk.text() if int(obj["step"]) == 0: obj["step"] = "1" Case.the().custom.mksmixing_step = self.mksmixing_step.text() Case.the().custom.mksmixing_init = self.mksmixing_init.text() Case.the().custom.mksmixing_mk = self.mksmixing_tracing.currentIndex() Case.the().custom.mksmixing_n1 = self.mksmixing_n1.text() Case.the().custom.mksmixing_n2 = self.mksmixing_n2.text() Case.the().custom.mksmixing_n3 = self.mksmixing_n3.text() Case.the().custom.mksmixing_calc = str( self.mksmixing_calc.currentIndex()) Case.the().custom.mksmixing_cdp = self.mksmixing_cdp.text() Case.the().custom.mksmixing_vtk = self.mksmixing_vtk.text() Case.the().custom.mksmixing_plot = self.mksmixing_plot.isChecked() file_tools.save_case(Case.the().path, Case.the()) mksmixing_export(obj, self.post_processing_widget, Case.the()) self.accept()
def on_apply_button(self): Case.the().custom.nnparam.rheology_treatment = str( self.execution_options_tab.rheology_treatment.currentIndex()) Case.the().custom.nnparam.velocity_gradient_type = str( self.execution_options_tab.velocity_gradient_type.currentIndex()) Case.the( ).custom.nnparam.relaxation_dt = self.execution_options_tab.relaxation_dt.text( ) Case.the( ).custom.nnparam.visco_treatment = self.execution_options_tab.visco_treatment.isChecked( ) for current_phase in range(self.fluid_phases_num): current_phase_dict = Case.the( ).custom.nnparam.tabs_list[current_phase] Case.the( ).custom.nnparam.tabs_list[current_phase]['phase_type'] = str( self.phases_parameters_tab_list[current_phase].phase_type. currentIndex()) Case.the().custom.nnparam.tabs_list[current_phase][ 'mk'] = self.fluids[current_phase] Case.the().custom.nnparam.tabs_list[current_phase][ 'rhop'] = self.phases_parameters_tab_list[ current_phase].phase_rhop.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'csound'] = self.phases_parameters_tab_list[ current_phase].phase_csound.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'gamma'] = self.phases_parameters_tab_list[ current_phase].phase_gamma.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'visco'] = self.phases_parameters_tab_list[ current_phase].phase_visco.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'tau_yield'] = self.phases_parameters_tab_list[ current_phase].phase_tau_yield.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'tau_max'] = self.phases_parameters_tab_list[ current_phase].phase_tau_max.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'bi_multi'] = self.phases_parameters_tab_list[ current_phase].phase_bi_multi.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'HBP_n'] = self.phases_parameters_tab_list[ current_phase].phase_HBP_n.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'HBP_m'] = self.phases_parameters_tab_list[ current_phase].phase_HBP_m.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'coh'] = self.phases_parameters_tab_list[ current_phase].phase_coh.text() Case.the().custom.nnparam.tabs_list[current_phase][ 'phi'] = self.phases_parameters_tab_list[ current_phase].phase_phi.text() file_tools.save_case(Case.the().path, Case.the()) Case.the().info.nonnewtonian_phase_list_exists = True self.close()