class NatureDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(NatureDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 3, 1) self.modelCombo.addItem(self.tr("liquid"), 'liquid') self.modelCombo.addItem(self.tr("gas"), 'gas') self.modelCombo.addItem(self.tr("solid"), 'solid') row = index.row() if (row == 0): self.modelCombo.disableItem(2) else: self.modelCombo.enableItem(2) editor.installEventFilter(self) return editor def setEditorData(self, comboBox, index): col = index.column() string = index.model().getData(index)[col] self.modelCombo.setItem(str_model=string) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] log.debug("NatureDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, value, Qt.DisplayRole) def tr(self, text): return text
class GlobalNumericalParametersView(QWidget, Ui_GlobalNumericalParameters): """ Global numerical parameters layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_GlobalNumericalParameters.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = GlobalNumericalParametersModel(self.case) # Combo model self.modelVelocityAlgorithm = ComboModel(self.comboBoxVelocityAlgorithm, 3, 1) self.modelVelocityAlgorithm.addItem(self.tr("Standard"), "standard_difvit") self.modelVelocityAlgorithm.addItem(self.tr("Coupled"), "coupled_difvitc") self.modelVelocityAlgorithm.addItem(self.tr("Mean velocity - relative velocity"), "mean_velocity_relative_velocity") mfm = MainFieldsModel(self.case) if len(mfm.getFieldIdList()) < 2 : self.modelVelocityAlgorithm.disableItem(2) else : self.modelVelocityAlgorithm.enableItem(2) # Validator validatorMaxRestart = IntValidator(self.lineEditMaxRestart, min = 0) validatorSplitting = DoubleValidator(self.lineEditTimeSplitting, min = 0.) validatorPRelax = DoubleValidator(self.lineEditPressureRelaxation, min = 0.) validatorMinP = DoubleValidator(self.lineEditMinimumPressure) validatorMaxP = DoubleValidator(self.lineEditMaximumPressure) validatorMaxRestart.setExclusiveMin(False) validatorSplitting.setExclusiveMin(True) validatorPRelax.setExclusiveMin(True) self.lineEditMaxRestart.setValidator(validatorMaxRestart) self.lineEditTimeSplitting.setValidator(validatorSplitting) self.lineEditPressureRelaxation.setValidator(validatorPRelax) self.lineEditMinimumPressure.setValidator(validatorMinP) self.lineEditMaximumPressure.setValidator(validatorMaxP) # Connections self.checkBoxRestart.clicked.connect(self.slotRestart) self.checkBoxPotentialState.clicked.connect(self.slotPotentialState) self.checkBoxFacesReconstruction.clicked.connect(self.slotFacesReconstruction) self.checkBoxMultigrid.clicked.connect(self.slotMultigrid) self.lineEditMinimumPressure.textChanged[str].connect(self.slotMinimumPressure) self.lineEditMaximumPressure.textChanged[str].connect(self.slotMaximumPressure) self.pushButtonAdvanced.clicked.connect(self.slotAdvancedOptions) self.lineEditMaxRestart.textChanged[str].connect(self.slotMaxRestart) self.lineEditTimeSplitting.textChanged[str].connect(self.slotTimeSplitting) self.lineEditPressureRelaxation.textChanged[str].connect(self.slotPressureRelaxation) self.checkBoxUpwindAlphaEnergy.clicked.connect(self.slotUpwindAlphaEnergy) self.checkBoxStopRestart.clicked.connect(self.slotStopRestart) self.comboBoxVelocityAlgorithm.activated[str].connect(self.slotVelocityAlgorithm) self.checkBoxRegulBadCells.clicked.connect(self.slotRegulateBadCells) # Initialize widget status = self.mdl.getRestartTimeStep() if status == 'on': self.checkBoxRestart.setChecked(1) self.groupBoxRestartOption.show() value = self.mdl.getMaxNumberOfRestart() self.lineEditMaxRestart.setText(str(value)) value = self.mdl.getTimeSplit() self.lineEditTimeSplitting.setText(str(value)) value = self.mdl.getPressureRelaxation() self.lineEditPressureRelaxation.setText(str(value)) status = self.mdl.getUpwindScheme() if status == 'on': self.checkBoxUpwindAlphaEnergy.setChecked(True) else : self.checkBoxUpwindAlphaEnergy.setChecked(False) status = self.mdl.getStopNoConvergence() if status == 'on': self.checkBoxStopRestart.setChecked(True) else : self.checkBoxStopRestart.setChecked(False) else : self.checkBoxRestart.setChecked(0) self.groupBoxRestartOption.hide() is_compressible = False for fid in mfm.getFieldIdList(): if mfm.getCompressibleStatus(int(fid)) == 'on': is_compressible = True break if is_compressible: self.mdl.setPotentielState('off') self.checkBoxPotentialState.setChecked(0) self.checkBoxPotentialState.setEnabled(False) else: status = self.mdl.getPotentielState() if status == 'on': self.checkBoxPotentialState.setChecked(1) else : self.checkBoxPotentialState.setChecked(0) status = self.mdl.getFacesReconstruction() if status == 'on': self.checkBoxFacesReconstruction.setChecked(1) else : self.checkBoxFacesReconstruction.setChecked(0) status = self.mdl.getRegulateBadCElls() self.checkBoxRegulBadCells.setChecked(status == 'on') status = self.mdl.getMultigridStatus() if status == 'on': self.checkBoxMultigrid.setChecked(1) else : self.checkBoxMultigrid.setChecked(0) value = self.mdl.getMinPressure() self.lineEditMinimumPressure.setText(str(value)) value = self.mdl.getMaxPressure() self.lineEditMaximumPressure.setText(str(value)) model = self.mdl.getVelocityPredictorAlgo() self.modelVelocityAlgorithm.setItem(str_model = model) self.case.undoStartGlobal() @pyqtSlot() def slotRestart(self): """ Input if restart time step if not converged """ if self.checkBoxRestart.isChecked(): self.mdl.setRestartTimeStep('on') self.groupBoxRestartOption.show() value = self.mdl.getMaxNumberOfRestart() self.lineEditMaxRestart.setText(str(value)) value = self.mdl.getTimeSplit() self.lineEditTimeSplitting.setText(str(value)) value = self.mdl.getPressureRelaxation() self.lineEditPressureRelaxation.setText(str(value)) status = self.mdl.getUpwindScheme() if status == 'on': self.checkBoxUpwindAlphaEnergy.setChecked(True) else : self.checkBoxUpwindAlphaEnergy.setChecked(False) status = self.mdl.getStopNoConvergence() if status == 'on': self.checkBoxStopRestart.setChecked(True) else : self.checkBoxStopRestart.setChecked(False) else: self.mdl.setRestartTimeStep('off') self.groupBoxRestartOption.hide() @pyqtSlot() def slotPotentialState(self): """ Input if restart time step if not converged """ if self.checkBoxPotentialState.isChecked(): self.mdl.setPotentielState('on') else: self.mdl.setPotentielState('off') @pyqtSlot() def slotFacesReconstruction(self): """ Input if faces reconstruction """ if self.checkBoxFacesReconstruction.isChecked(): self.mdl.setFacesReconstruction('on') self.checkBoxFacesReconstruction.setChecked(1) else: self.mdl.setFacesReconstruction('off') @pyqtSlot() def slotMultigrid(self): """ Input if multigrid for pressure """ if self.checkBoxMultigrid.isChecked(): self.mdl.setMultigridStatus('on') else: self.mdl.setMultigridStatus('off') @pyqtSlot(str) def slotMinimumPressure(self, text): """ Input value of minimum pressure """ if self.lineEditMinimumPressure.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMinPressure(value) @pyqtSlot(str) def slotMaximumPressure(self, text): """ Input value of maximum pressure """ if self.lineEditMaximumPressure.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMaxPressure(value) @pyqtSlot() def slotAdvancedOptions(self): """ Ask one popup for advanced specifications """ default = {} default['velocity_update'] = self.mdl.getVelocityUpdate() default['pressure_symetrisation'] = self.mdl.getPressureSymetrisation() default['pressure_gradient'] = self.mdl.getPressureGradient() default['max_sum_alpha'] = self.mdl.getSumAlpha() default['alpha_p_cycle'] = self.mdl.getAlphaPressureCycles() log.debug("slotAdvancedOptions -> %s" % str(default)) dialog = GlobalNumericalParametersAdvancedOptionsDialogView(self, self.case, default) if dialog.exec_(): result = dialog.get_result() log.debug("slotAdvancedOptions -> %s" % str(result)) self.mdl.setVelocityUpdate(result['velocity_update']) self.mdl.setPressureSymetrisation(result['pressure_symetrisation']) self.mdl.setPressureGradient(result['pressure_gradient']) self.mdl.setSumAlpha(result['max_sum_alpha']) self.mdl.setAlphaPressureCycles(result['alpha_p_cycle']) @pyqtSlot(str) def slotMaxRestart(self, text): """ Input value of Maximum number of restart """ if self.lineEditMaxRestart.validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.mdl.setMaxNumberOfRestart(value) @pyqtSlot(str) def slotTimeSplitting(self, text): """ Input value of time-step splitting """ if self.lineEditTimeSplitting.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setTimeSplit(value) @pyqtSlot(str) def slotPressureRelaxation(self, text): """ Input value of pressure increment relaxation """ if self.lineEditPressureRelaxation.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setPressureRelaxation(value) @pyqtSlot() def slotUpwindAlphaEnergy(self): """ Input if upwind scheme for mass and energy """ if self.checkBoxUpwindAlphaEnergy.isChecked(): self.mdl.setUpwindScheme('on') else: self.mdl.setUpwindScheme('off') @pyqtSlot() def slotStopRestart(self): """ Input if stop if no convergence """ if self.checkBoxStopRestart.isChecked(): self.mdl.setStopNoConvergence('on') else: self.mdl.setStopNoConvergence('off') @pyqtSlot(str) def slotVelocityAlgorithm(self, text): """ Input velocity algorithm model """ model = self.modelVelocityAlgorithm.dicoV2M[str(text)] self.mdl.setVelocityPredictorAlgo(model) @pyqtSlot() def slotRegulateBadCells(self): """ Activate bad cells regulations. """ if self.checkBoxRegulBadCells.isChecked(): self.mdl.setRegulateBadCells('on') else: self.mdl.setRegulateBadCells('off') def tr(self, text): """ Translation """ return text
class InterfacialAreaView(QWidget, Ui_InterfacialArea): """ InterfacialAreaView layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_InterfacialArea.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = InterfacialAreaModel(self.case) dispersed_fields = self.mdl.getDispersedFieldList( ) + InterfacialForcesModel(self.case).getGLIMfields() if dispersed_fields == []: self.groupBoxField.hide() self.groupBoxMinMaxDiameter.hide() self.groupBoxModel.hide() self.labelNoDispersedPhase.show() self.mdl.remove() return # Combo box models id_to_set = -1 self.modelField = ComboModel(self.comboBoxField, 1, 1) # For consistency with the previous pages, the second phase of the # Large Interface Model is set before the dispersed fields for fieldId in dispersed_fields: label = self.mdl.getLabel(fieldId) name = str(fieldId) self.modelField.addItem(self.tr(label), name) if len(dispersed_fields) > 0 and id_to_set == -1: id_to_set = dispersed_fields[0] self.modelField.setItem(str_model=id_to_set) # case no field self.currentid = id_to_set self.modelModel = ComboModel(self.comboBoxModel, 2, 1) self.modelModel.addItem(self.tr("constant"), "constant") self.modelModel.addItem(self.tr("interfacial area transport"), "interfacial_area_transport") self.modelSourceTerm = ComboModel(self.comboBoxSourceTerm, 4, 1) self.modelSourceTerm.addItem( self.tr("No coalescence, no fragmentation"), "no_coalescence_no_fragmentation") self.modelSourceTerm.addItem(self.tr("Yao & Morel"), "wei_yao") self.modelSourceTerm.addItem(self.tr("Kamp & Colin"), "kamp_colin") self.modelSourceTerm.addItem(self.tr("Ruyer & Seiler"), "ruyer_seiler") self.modelSourceTerm.disableItem(2) # Why ? # Validators validatorDefDiam = DoubleValidator(self.lineEditDefaultDiameter, min=0.0) validatorMinDiam = DoubleValidator(self.lineEditMinDiameter, min=0.0) validatorMaxDiam = DoubleValidator(self.lineEditMaxDiameter, min=0.0) validatorDefDiam.setExclusiveMin(True) validatorMinDiam.setExclusiveMin(True) validatorMaxDiam.setExclusiveMin(True) self.lineEditDefaultDiameter.setValidator(validatorDefDiam) self.lineEditMinDiameter.setValidator(validatorMinDiam) self.lineEditMaxDiameter.setValidator(validatorMaxDiam) # Connect signals to slots self.comboBoxField.activated[str].connect(self.slotField) self.comboBoxModel.activated[str].connect(self.slotModel) self.comboBoxSourceTerm.activated[str].connect(self.slotSourceTerm) self.lineEditDefaultDiameter.textChanged[str].connect( self.slotDefaultDiameter) self.lineEditMinDiameter.textChanged[str].connect(self.slotMinDiameter) self.lineEditMaxDiameter.textChanged[str].connect(self.slotMaxDiameter) # Initialize widget self.initializeVariables(self.currentid) self.case.undoStartGlobal() @pyqtSlot(str) def slotField(self, text): """ INPUT label for choice of field """ self.currentid = self.modelField.dicoV2M[text] self.initializeVariables(self.currentid) if self.mdl.getFieldNature(self.currentid) == "gas": self.modelSourceTerm.enableItem(0) else: self.modelSourceTerm.disableItem(0) @pyqtSlot(str) def slotModel(self, text): """ INPUT type for choice of model """ model = self.modelModel.dicoV2M[text] self.mdl.setAreaModel(self.currentid, model) self.initializeVariables(self.currentid) @pyqtSlot(str) def slotSourceTerm(self, text): """ INPUT type for choice of model source term """ model = self.modelSourceTerm.dicoV2M[text] self.mdl.setSourceTerm(self.currentid, model) @pyqtSlot(str) def slotDefaultDiameter(self, var): """ """ if self.lineEditDefaultDiameter.validator( ).state == QValidator.Acceptable: value = from_qvariant(var, float) self.mdl.setInitialDiameter(self.currentid, value) @pyqtSlot(str) def slotMinDiameter(self, var): """ """ if self.lineEditMinDiameter.validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.mdl.setMinDiameter(self.currentid, value) @pyqtSlot(str) def slotMaxDiameter(self, var): """ """ if self.lineEditMaxDiameter.validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.mdl.setMaxDiameter(self.currentid, value) def initializeVariables(self, fieldId): """ Initialize variables when a new fieldId is choosen """ self.labelNoDispersedPhase.hide() model = self.mdl.getAreaModel(fieldId) self.modelModel.setItem(str_model=model) value = self.mdl.getInitialDiameter(self.currentid) self.lineEditDefaultDiameter.setText(str(value)) if self.mdl.getAreaModel(fieldId) == "constant": self.groupBoxAreaTransport.hide() self.groupBoxMinMaxDiameter.hide() else: self.groupBoxAreaTransport.show() model = self.mdl.getSourceTerm(fieldId) self.modelSourceTerm.setItem(str_model=model) self.groupBoxMinMaxDiameter.show() value = self.mdl.getMinDiameter(self.currentid) self.lineEditMinDiameter.setText(str(value)) value = self.mdl.getMaxDiameter(self.currentid) self.lineEditMaxDiameter.setText(str(value)) if MainFieldsModel(self.case).getFieldNature(fieldId) != 'gas': self.modelSourceTerm.disableItem(1) self.modelSourceTerm.disableItem(2) self.modelSourceTerm.disableItem(3) else:
class SolutionVerifView(QWidget, Ui_SolutionVerifForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_SolutionVerifForm.__init__(self) self.setupUi(self) self.parent = parent self.case = case self.case.undoStopGlobal() self.mdl = SolutionDomainModel(self.case) self.out = OutputControlModel(self.case) self.case2 = Case(package = self.case['package'], file_name = None) XMLinit(self.case2).initialize() self.case2['xmlfile'] = 'cs_cmd' self.case2['salome'] = self.case['salome'] self.node_domain = self.case.xmlGetNode('solution_domain') faces_cutting = self.node_domain.xmlGetNode('faces_cutting') joining = self.node_domain.xmlGetNode('joining') periodicity = self.node_domain.xmlGetNode('periodicity') sd_node = self.case2.xmlGetNode('solution_domain') if faces_cutting != None: if (faces_cutting)['status'] == 'on': sd_node.xmlInitNode('faces_cutting', status='on').xmlChildsCopy(faces_cutting) if joining != None: sd_node.xmlInitNode('joining').xmlChildsCopy(joining) if periodicity != None: sd_node.xmlInitNode('periodicity').xmlChildsCopy(periodicity) self.out2 = OutputControlModel(self.case2) # combo models self.modelFMTCHR = ComboModel(self.comboBoxFMTCHR, 3, 1) self.modelFormat = ComboModel(self.comboBoxFormat, 2, 1) self.modelPolygon = ComboModel(self.comboBoxPolygon, 3, 1) self.modelPolyhedra = ComboModel(self.comboBoxPolyhedra, 3, 1) self.modelFMTCHR.addItem(self.tr("EnSight Gold"), 'ensight') self.modelFMTCHR.addItem(self.tr("MED"), 'med') self.modelFMTCHR.addItem(self.tr("CGNS"), 'cgns') self.modelFMTCHR.addItem(self.tr("Catalyst"), 'catalyst') self.modelFMTCHR.addItem(self.tr("CCM-IO"), 'ccm') import cs_config cfg = cs_config.config() if cfg.libs['med'].have == "no": self.comboBoxFMTCHR.setItemData(1, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['cgns'].have == "no": self.comboBoxFMTCHR.setItemData(2, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['catalyst'].have == "no": self.comboBoxFMTCHR.setItemData(3, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['ccm'].have == "no": self.comboBoxFMTCHR.setItemData(4, QColor(Qt.red), Qt.TextColorRole); self.modelFormat.addItem(self.tr("binary"), 'binary') self.modelFormat.addItem(self.tr("text"), 'text') self.modelPolygon.addItem(self.tr("display"), 'display') self.modelPolygon.addItem(self.tr("discard"), 'discard_polygons') self.modelPolygon.addItem(self.tr("subdivide"), 'divide_polygons') self.modelPolyhedra.addItem(self.tr("display"), 'display') self.modelPolyhedra.addItem(self.tr("discard"), 'discard_polyhedra') self.modelPolyhedra.addItem(self.tr("subdivide"), 'divide_polyhedra') # connections self.connect(self.comboBoxFMTCHR, SIGNAL("activated(const QString&)"), self.slotOutputFormat) self.connect(self.comboBoxFormat, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.comboBoxPolygon, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.comboBoxPolyhedra, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.checkBoxBigEndian, SIGNAL("clicked()"), self.slotOutputOptions) self.connect(self.toolButtonBatch, SIGNAL("clicked()"), self.slotMeshChecking) # INITIALISATIONS # 1 - Values of post processing's format fmt = self.out.getWriterFormat("-1") self.modelFMTCHR.setItem(str_model=fmt) line = self.out.getWriterOptions("-1") self.__updateOptionsFormat(line) if not (self.mdl.getMeshList() or self.mdl.getMeshInput()): self.toolButtonBatch.setEnabled(False) self.case.undoStartGlobal() @pyqtSignature("const QString &") def slotOutputFormat(self, text): """ Input format of post-processing """ format = self.modelFMTCHR.dicoV2M[str(text)] if self.out.getWriterFormat("-1") != format: self.out.setWriterFormat("-1",format) l = self.out.defaultWriterValues()['options'] self.out.setWriterOptions("-1",l) if self.out2.getWriterFormat("-1") != format: self.out2.setWriterFormat("-1",format) l = self.out2.defaultWriterValues()['options'] self.out2.setWriterOptions("-1",l) self.__updateOptionsFormat(l) @pyqtSignature("") def slotOutputOptions(self): """ Create format's command line options """ line = [] opt_format = self.modelFormat.dicoV2M[str(self.comboBoxFormat.currentText())] line.append(opt_format) if self.checkBoxBigEndian.isChecked(): line.append('big_endian') opt_polygon = self.modelPolygon.dicoV2M[str(self.comboBoxPolygon.currentText())] opt_polyhed = self.modelPolyhedra.dicoV2M[str(self.comboBoxPolyhedra.currentText())] if opt_polygon != 'display': line.append(opt_polygon) if opt_polyhed != 'display': line.append(opt_polyhed) l = string.join(line, ',') log.debug("slotOutputOptions-> OPTCHR = %s" % l) self.out.setWriterOptions("-1",l) self.out2.setWriterOptions("-1",l) def __updateOptionsFormat(self, line): """ Update command-line options at each modification of post processing format """ lst = line.split(',') format = self.modelFMTCHR.dicoV2M[str(self.comboBoxFMTCHR.currentText())] log.debug("__updateOptionsFormat-> FMTCHR = %s" % format) log.debug("__updateOptionsFormat-> OPTCHR = %s" % line) # update widgets from the options list for opt in lst: if opt == 'binary' or opt == 'text' : self.modelFormat.setItem(str_model=opt) if opt == 'discard_polygons' or opt == 'divide_polygons': self.modelPolygon.setItem(str_model=opt) if opt == 'discard_polyhedra' or opt == 'divide_polyhedra': self.modelPolyhedra.setItem(str_model=opt) if format == 'ensight': if opt == 'big_endian': self.checkBoxBigEndian.setChecked(True) if 'discard_polygons' not in lst and 'divide_polygons' not in lst: self.modelPolygon.setItem(str_model="display") if 'discard_polyhedra' not in lst and 'divide_polyhedra' not in lst: self.modelPolyhedra.setItem(str_model="display") if 'big_endian' not in lst: self.checkBoxBigEndian.setChecked(False) # enable and disable options related to the format self.modelPolygon.enableItem(str_model='discard_polygons') self.modelPolygon.enableItem(str_model='divide_polygons') self.modelPolyhedra.enableItem(str_model='discard_polyhedra') self.modelPolyhedra.enableItem(str_model='divide_polyhedra') self.comboBoxPolygon.setEnabled(True) self.comboBoxPolyhedra.setEnabled(True) if format != "ensight": if format == "cgns": self.modelPolyhedra.setItem(str_model='divide_polyhedra') self.modelPolyhedra.disableItem(str_model='display') elif format in ["catalyst", "ccm"]: self.modelPolyhedra.setItem(str_model='display') self.modelPolygon.setItem(str_model='display') self.comboBoxPolygon.setEnabled(False) self.comboBoxPolyhedra.setEnabled(False) self.modelFormat.setItem(str_model="binary") self.modelFormat.disableItem(str_model='text') self.labelBigEndian.setEnabled(False) self.checkBoxBigEndian.setEnabled(False) else: self.modelFormat.enableItem(str_model='text') self.comboBoxFormat.setEnabled(True) self.labelBigEndian.setEnabled(True) self.checkBoxBigEndian.setEnabled(True) def __setButtonEnabled(self): """ Block the QButton during the display of the dialog. """ try: self.toolButtonBatch.setEnabled(not self.toolButtonBatch.isEnabled()) except: pass def slotMeshChecking(self): """ """ self.__setButtonEnabled() dialog = MeshQualityCriteriaLogDialogView(self.parent, self.case, self.case2) dialog.show() self.connect(dialog, SIGNAL("accepted()"), self.__setButtonEnabled) self.connect(dialog, SIGNAL("rejected()"), self.__setButtonEnabled) def tr(self, text): """ Translation """ return text
class NumericalParamGlobalView(QWidget, Ui_NumericalParamGlobalForm): """ """ def __init__(self, parent, case, tree): """ Constructor """ QWidget.__init__(self, parent) Ui_NumericalParamGlobalForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = NumericalParamGlobalModel(self.case) self.browser = tree self.labelSRROM.hide() self.lineEditSRROM.hide() self.line_5.hide() # Combo models self.modelEXTRAG = ComboModel(self.comboBoxEXTRAG,2,1) self.modelIMRGRA = ComboModel(self.comboBoxIMRGRA,5,1) self.modelNTERUP = ComboModel(self.comboBoxNTERUP,3,1) self.modelEXTRAG.addItem(self.tr("Neumann 1st order"), 'neumann') self.modelEXTRAG.addItem(self.tr("Extrapolation"), 'extrapolation') self.modelIMRGRA.addItem(self.tr("Iterative handling of non-orthogonalities"),'0') self.modelIMRGRA.addItem(self.tr("Least squares method over neighboring cells"),'1') self.modelIMRGRA.addItem(self.tr("Least squares method over extended cell neighborhood"),'2') self.modelIMRGRA.addItem(self.tr("Least squares method over partial extended cell neighborhood"),'3') self.modelIMRGRA.addItem(self.tr("Iterative method with least squares initialization"),'4') self.modelNTERUP.addItem(self.tr("SIMPLE"), 'simple') self.modelNTERUP.addItem(self.tr("SIMPLEC"),'simplec') self.modelNTERUP.addItem(self.tr("PISO"),'piso') self.comboBoxEXTRAG.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.comboBoxNTERUP.setSizeAdjustPolicy(QComboBox.AdjustToContents) # Connections self.connect(self.checkBoxIVISSE, SIGNAL("clicked()"), self.slotIVISSE) self.connect(self.checkBoxIPUCOU, SIGNAL("clicked()"), self.slotIPUCOU) self.connect(self.checkBoxICFGRP, SIGNAL("clicked()"), self.slotICFGRP) self.connect(self.checkBoxImprovedPressure, SIGNAL("clicked()"), self.slotImprovedPressure) self.connect(self.comboBoxEXTRAG, SIGNAL("activated(const QString&)"), self.slotEXTRAG) self.connect(self.lineEditRELAXP, SIGNAL("textChanged(const QString &)"), self.slotRELAXP) self.connect(self.comboBoxIMRGRA, SIGNAL("activated(const QString&)"), self.slotIMRGRA) self.connect(self.lineEditSRROM, SIGNAL("textChanged(const QString &)"), self.slotSRROM) self.connect(self.comboBoxNTERUP, SIGNAL("activated(const QString&)"), self.slotNTERUP) self.connect(self.spinBoxNTERUP, SIGNAL("valueChanged(int)"), self.slotNTERUP2) # Validators validatorRELAXP = DoubleValidator(self.lineEditRELAXP, min=0., max=1.) validatorRELAXP.setExclusiveMin(True) validatorSRROM = DoubleValidator(self.lineEditSRROM, min=0., max=1.) validatorSRROM.setExclusiveMin(True) self.lineEditRELAXP.setValidator(validatorRELAXP) self.lineEditSRROM.setValidator(validatorSRROM) if self.model.getTransposedGradient() == 'on': self.checkBoxIVISSE.setChecked(True) else: self.checkBoxIVISSE.setChecked(False) if self.model.getVelocityPressureCoupling() == 'on': self.checkBoxIPUCOU.setChecked(True) else: self.checkBoxIPUCOU.setChecked(False) import code_saturne.Pages.FluidCharacteristicsModel as FluidCharacteristics fluid = FluidCharacteristics.FluidCharacteristicsModel(self.case) modl_atmo, modl_joul, modl_thermo, modl_gas, modl_coal, modl_comp = fluid.getThermoPhysicalModel() if self.model.getHydrostaticPressure() == 'on': self.checkBoxImprovedPressure.setChecked(True) else: self.checkBoxImprovedPressure.setChecked(False) self.lineEditRELAXP.setText(str(self.model.getPressureRelaxation())) self.modelEXTRAG.setItem(str_model=self.model.getWallPressureExtrapolation()) self.modelIMRGRA.setItem(str_model=str(self.model.getGradientReconstruction())) if modl_joul != 'off' or modl_gas != 'off' or modl_coal != 'off': self.labelSRROM.show() self.lineEditSRROM.show() self.lineEditSRROM.setText(str(self.model.getDensityRelaxation())) self.line_5.show() algo = self.model.getVelocityPressureAlgorithm() status = SteadyManagementModel(self.case).getSteadyFlowManagement() if status == 'on': self.modelNTERUP.enableItem(str_model = 'simple') self.modelNTERUP.disableItem(str_model = 'piso') else: self.modelNTERUP.disableItem(str_model = 'simple') self.modelNTERUP.enableItem(str_model = 'piso') self.modelNTERUP.setItem(str_model=algo) if algo == 'piso': self.spinBoxNTERUP.show() else: self.spinBoxNTERUP.hide() if modl_comp != 'off': self.labelICFGRP.show() self.checkBoxICFGRP.show() self.line_4.show() if self.model.getHydrostaticEquilibrium() == 'on': self.checkBoxICFGRP.setChecked(True) else: self.checkBoxICFGRP.setChecked(False) self.checkBoxIPUCOU.hide() self.labelIPUCOU.hide() self.lineEditRELAXP.hide() self.labelRELAXP.hide() self.checkBoxImprovedPressure.hide() self.labelImprovedPressure.hide() self.line_2.hide() self.line_5.hide() self.line_7.hide() self.line_8.hide() self.labelNTERUP.setText("Velocity-Pressure algorithm\nsub-iterations on Navier-Stokes") self.comboBoxNTERUP.hide() self.spinBoxNTERUP.show() else: self.labelICFGRP.hide() self.checkBoxICFGRP.hide() self.line_4.hide() self.checkBoxIPUCOU.show() self.labelIPUCOU.show() self.lineEditRELAXP.show() self.labelRELAXP.show() self.checkBoxImprovedPressure.show() self.labelImprovedPressure.show() self.line_2.show() self.line_5.show() self.line_7.show() self.line_8.show() value = self.model.getPisoSweepNumber() self.spinBoxNTERUP.setValue(value) # Update the Tree files and folders self.browser.configureTree(self.case) self.case.undoStartGlobal() @pyqtSignature("") def slotIVISSE(self): """ Set value for parameter IVISSE """ if self.checkBoxIVISSE.isChecked(): self.model.setTransposedGradient("on") else: self.model.setTransposedGradient("off") @pyqtSignature("") def slotIPUCOU(self): """ Set value for parameter IPUCOU """ if self.checkBoxIPUCOU.isChecked(): self.model.setVelocityPressureCoupling("on") else: self.model.setVelocityPressureCoupling("off") @pyqtSignature("") def slotICFGRP(self): """ Set value for parameter IPUCOU """ if self.checkBoxICFGRP.isChecked(): self.model.setHydrostaticEquilibrium("on") else: self.model.setHydrostaticEquilibrium("off") @pyqtSignature("") def slotImprovedPressure(self): """ Input IHYDPR. """ if self.checkBoxImprovedPressure.isChecked(): self.model.setHydrostaticPressure("on") else: self.model.setHydrostaticPressure("off") @pyqtSignature("const QString &") def slotEXTRAG(self, text): """ Set value for parameter EXTRAG """ extrag = self.modelEXTRAG.dicoV2M[str(text)] self.model.setWallPressureExtrapolation(extrag) log.debug("slotEXTRAG-> %s" % extrag) @pyqtSignature("const QString &") def slotRELAXP(self, text): """ Set value for parameter RELAXP """ if self.sender().validator().state == QValidator.Acceptable: relaxp = from_qvariant(text, float) self.model.setPressureRelaxation(relaxp) log.debug("slotRELAXP-> %s" % relaxp) @pyqtSignature("const QString &") def slotSRROM(self, text): """ Set value for parameter SRROM """ if self.sender().validator().state == QValidator.Acceptable: srrom = from_qvariant(text, float) self.model.setDensityRelaxation(srrom) log.debug("slotSRROM-> %s" % srrom) @pyqtSignature("const QString &") def slotIMRGRA(self, text): """ Set value for parameter IMRGRA """ imrgra = self.modelIMRGRA.getIndex(str_view=str(text)) self.model.setGradientReconstruction(imrgra) log.debug("slotIMRGRA-> %s" % imrgra) @pyqtSignature("const QString &") def slotNTERUP(self,text): """ Set value for parameterNTERUP """ NTERUP = self.modelNTERUP.dicoV2M[str(text)] self.model.setVelocityPressureAlgorithm(NTERUP) if NTERUP == 'piso': self.spinBoxNTERUP.show() value = self.model.getPisoSweepNumber() self.spinBoxNTERUP.setValue(value) else: self.spinBoxNTERUP.hide() self.browser.configureTree(self.case) log.debug("slotNTERUP-> %s" % NTERUP) @pyqtSignature("const QString &") def slotNTERUP2(self, var): """ Set value for parameter piso sweep number """ self.model.setPisoSweepNumber(var) log.debug("slotNTERUP2-> %s" % var) def tr(self, text): """ Translation """ return text
class ThermalRadiationView(QWidget, Ui_ThermalRadiationForm): """ Class to open Thermal Scalar Transport Page. """ def __init__(self, parent, case, tree): """ Constructor """ QWidget.__init__(self, parent) Ui_ThermalRadiationForm.__init__(self) self.setupUi(self) self.browser = tree self.case = case self.case.undoStopGlobal() self.mdl = ThermalRadiationModel(self.case) # Combo models self.modelRadModel = ComboModel(self.comboBoxRadModel, 3, 1) self.modelDirection = ComboModel(self.comboBoxQuadrature, 8, 1) self.modelAbsorption = ComboModel(self.comboBoxAbsorption, 3, 1) self.modelRadModel.addItem("No radiative transfers", 'off') self.modelRadModel.addItem("Discrete ordinates method", 'dom') self.modelRadModel.addItem("P-1 Model", 'p-1') self.modelDirection.addItem("24 directions (S4)", "1") self.modelDirection.addItem("48 directions (S6)", "2") self.modelDirection.addItem("80 directions (S8)", "3") self.modelDirection.addItem("32 directions (T2)", "4") self.modelDirection.addItem("128 directions (T4)", "5") self.modelDirection.addItem("8n^2 directions (Tn)", "6") self.modelDirection.addItem("120 directions (LC11)", "7") self.modelDirection.addItem("48 directions (DCT020-2468)", "8") # Connections self.connect(self.comboBoxRadModel, SIGNAL("activated(const QString&)"), self.slotRadiativeTransfer) self.connect(self.radioButtonOn, SIGNAL("clicked()"), self.slotStartRestart) self.connect(self.radioButtonOff, SIGNAL("clicked()"), self.slotStartRestart) self.connect(self.comboBoxQuadrature, SIGNAL("activated(const QString&)"), self.slotDirection) self.connect(self.lineEditNdirec, SIGNAL("textChanged(const QString &)"), self.slotNdirec) self.connect(self.comboBoxAbsorption, SIGNAL("activated(const QString&)"), self.slotTypeCoefficient) self.connect(self.lineEditCoeff, SIGNAL("textChanged(const QString &)"), self.slotAbsorptionCoefficient) self.connect(self.toolButtonAdvanced, SIGNAL("clicked()"), self.slotAdvancedOptions) # Validator validatorCoeff = DoubleValidator(self.lineEditCoeff, min=0.0) self.lineEditCoeff.setValidator(validatorCoeff) validatorNdir = IntValidator(self.lineEditNdirec, min=3) self.lineEditNdirec.setValidator(validatorNdir) self.modelAbsorption.addItem('constant', 'constant') self.modelAbsorption.addItem('user subroutine (usray3)', 'variable') self.modelAbsorption.addItem('user law', 'formula') self.modelAbsorption.addItem('H2O and CO2 mixing (Modak)', 'modak') from code_saturne.Pages.CoalCombustionModel import CoalCombustionModel if CoalCombustionModel(self.case).getCoalCombustionModel() != "off": self.modelAbsorption.disableItem(str_model='variable') self.modelAbsorption.enableItem(str_model='modak') else: self.modelAbsorption.disableItem(str_model='modak') self.modelAbsorption.enableItem(str_model='variable') del CoalCombustionModel self.modelAbsorption.disableItem(str_model='formula') # Initialization self.modelRadModel.setItem(str_model=self.mdl.getRadiativeModel()) self.slotRadiativeTransfer() if self.mdl.getRestart() == 'on': self.radioButtonOn.setChecked(True) self.radioButtonOff.setChecked(False) else: self.radioButtonOn.setChecked(False) self.radioButtonOff.setChecked(True) value = self.mdl.getTypeCoeff() self.modelAbsorption.setItem(str_model=value) self.slotTypeCoefficient(self.modelAbsorption.dicoM2V[value]) self.pushButtonCoeffFormula.setEnabled(False) self.lineEditCoeff.setText(str(self.mdl.getAbsorCoeff())) self.case.undoStartGlobal() @pyqtSignature("const QString &") def slotRadiativeTransfer(self): """ """ model = self.modelRadModel.dicoV2M[str(self.comboBoxRadModel.currentText())] self.mdl.setRadiativeModel(model) if model == 'off': self.frameOptions.hide() self.line.hide() else: self.frameOptions.show() self.line.show() if model == 'p-1': self.frameDirection.hide() elif model == 'dom': self.frameDirection.show() n = self.mdl.getQuadrature() self.modelDirection.setItem(str_model=str(n)) if str(n) == "6": self.label_2.show() self.lineEditNdirec.show() self.lineEditNdirec.setText(str(self.mdl.getNbDir())) else: self.label_2.hide() self.lineEditNdirec.hide() self.browser.configureTree(self.case) @pyqtSignature("") def slotStartRestart(self): """ """ if self.radioButtonOn.isChecked(): self.mdl.setRestart("on") else: self.mdl.setRestart("off") @pyqtSignature("const QString &") def slotDirection(self, text): """ """ n = int(self.modelDirection.dicoV2M[str(text)]) self.mdl.setQuadrature(n) if n == 6: self.label_2.show() self.lineEditNdirec.show() self.lineEditNdirec.setText(str(self.mdl.getNbDir())) else: self.label_2.hide() self.lineEditNdirec.hide() @pyqtSignature("const QString &") def slotNdirec(self, text): """ """ if self.sender().validator().state == QValidator.Acceptable: n = from_qvariant(text, int) self.mdl.setNbDir(n) @pyqtSignature("const QString &") def slotTypeCoefficient(self, text): """ """ typeCoeff = self.modelAbsorption.dicoV2M[str(text)] self.mdl.setTypeCoeff(typeCoeff) if typeCoeff == 'constant': self.lineEditCoeff.setEnabled(True) elif typeCoeff == 'modak': self.lineEditCoeff.setDisabled(True) else: self.lineEditCoeff.setDisabled(True) @pyqtSignature("const QString &") def slotAbsorptionCoefficient(self, text): """ """ if self.sender().validator().state == QValidator.Acceptable: c = from_qvariant(text, float) self.mdl.setAbsorCoeff(c) @pyqtSignature("") def slotAdvancedOptions(self): """ Ask one popup for advanced specifications """ default = {} default['frequency'] = self.mdl.getFrequency() default['idiver'] = self.mdl.getTrs() default['tempP'] = self.mdl.getTemperatureListing() default['intensity'] = self.mdl.getIntensityResolution() default['model'] = self.mdl.getRadiativeModel() log.debug("slotAdvancedOptions -> %s" % str(default)) dialog = ThermalRadiationAdvancedDialogView(self, self.case, default) if dialog.exec_(): result = dialog.get_result() log.debug("slotAdvancedOptions -> %s" % str(result)) self.mdl.setFrequency(result['frequency']) self.mdl.setTrs(result['idiver']) self.mdl.setTemperatureListing(result['tempP']) self.mdl.setIntensityResolution(result['intensity']) def tr(self, text): """ Translation """ return text