class CouplingDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, mdl, dicoM2V, dicoV2M): super(CouplingDelegate, self).__init__(parent) self.parent = parent self.mdl = mdl self.dicoM2V = dicoM2V self.dicoV2M = dicoV2M def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) fieldId = index.row() + 1 if self.mdl.getCriterion(fieldId) == "continuous": self.modelCombo.addItem(self.tr(self.dicoM2V["none"]), "none") self.modelCombo.disableItem(str_model="none") else: self.modelCombo.addItem(self.tr(self.dicoM2V["none"]), "none") carrier = self.mdl.getCarrierField(fieldId) if self.mdl.getTurbulenceModel(carrier) == "k-epsilon" or \ self.mdl.getTurbulenceModel(carrier) == "k-epsilon_linear_production" or \ self.mdl.getTurbulenceModel(carrier) == "rij-epsilon_ssg" or \ self.mdl.getTurbulenceModel(carrier) == "rij-epsilon_ebrsm": if self.mdl.getFieldNature(fieldId) == "gas": # bulles self.modelCombo.addItem( self.tr(self.dicoM2V["large_inclusions"]), "large_inclusions") else: # gouttes et solide self.modelCombo.addItem( self.tr(self.dicoM2V["small_inclusions"]), "small_inclusions") editor.setMinimumSize(editor.sizeHint()) editor.installEventFilter(self) return editor def setEditorData(self, comboBox, index): row = index.row() col = index.column() string = index.model().getData(index)[col] self.modelCombo.setItem(str_view=string) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] log.debug("CouplingDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, self.dicoM2V[value], Qt.DisplayRole) def tr(self, text): return text
class TurbFluxDelegate(QItemDelegate): """ Use of a combobox in the table. """ def __init__(self, parent, mdl, dicoM2V, dicoV2M): super(TurbFluxDelegate, self).__init__(parent) self.parent = parent self.mdl = mdl self.dicoM2V = dicoM2V self.dicoV2M = dicoV2M def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) fieldId = index.row() + 1 if self.mdl.getEnergyResolution(fieldId) == 'on': if self.mdl.useAdvancedThermalFluxes(fieldId) == True: for turbFlux in TurbulenceModelsDescription.ThermalTurbFluxModels: self.modelCombo.addItem(self.tr(self.dicoM2V[turbFlux]), turbFlux) else: turb_flux = TurbulenceModelsDescription.ThermalTurbFluxModels[ 0] self.modelCombo.addItem(self.tr(self.dicoM2V[turbFlux]), turbFlux) self.modelCombo.disableItem(index=0) else: self.modelCombo.addItem(self.tr(self.dicoM2V['none']), 'none') self.modelCombo.setItem(str_view='none') editor.setMinimumSize(editor.sizeHint()) editor.installEventFilter(self) return editor def setEditorData(self, comboBox, index): row = index.row() col = index.column() string = index.model().getData(index)[col] self.modelCombo.setItem(str_view=string) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] log.debug("TurbFluxDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(self.dicoM2V[value]), Qt.DisplayRole) def tr(self, text): return text
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 CriterionDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(CriterionDelegate, 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("continuous"), 'continuous') self.modelCombo.addItem(self.tr("dispersed"), 'dispersed') self.modelCombo.addItem(self.tr("auto"), 'auto') # TODO a supprimer quand existant self.modelCombo.disableItem(2) # fixed to continuous for field 1 if index.row() == 0: editor.setEnabled(False) editor.installEventFilter(self) return editor def setEditorData(self, comboBox, index): row = index.row() 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("CriterionDelegate 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 MainFieldsInitializationView(QWidget, Ui_MainFieldsInitialization): """ Main fields layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_MainFieldsInitialization.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = MainFieldsInitializationModel(self.case) self.volzone = LocalizationModel('VolumicZone', self.case) self.NonCondensable = NonCondensableModel(self.case) self.SpeciesModel = SpeciesModel(self.case) # Combo box models self.modelVolumeZone = ComboModel(self.comboBoxVolumeZone, 1, 1) self.zone = "" zones = self.volzone.getZones() for zone in zones: if zone.getNature()['initialization'] == "on": label = zone.getLabel() name = str(zone.getCodeNumber()) self.modelVolumeZone.addItem(self.tr(label), name) if label == "all_cells": self.zone = name if not self.zone: self.zone = name self.modelVolumeZone.setItem(str_model = self.zone) self.modelField = ComboModel(self.comboBoxField, 1, 1) for fieldId in self.mdl.getFieldIdList() : label = self.mdl.getLabel(fieldId) name = str(fieldId) self.modelField.addItem(self.tr(label), name) self.currentid = -1 if len(self.mdl.getFieldIdList()) > 0 : self.currentid = self.mdl.getFieldIdList()[0] self.modelField.setItem(str_model = self.currentid) self.modelEnergy = ComboModel(self.comboBoxEnergy, 3, 1) self.modelEnergy.addItem(self.tr("Enthalpy"), "enthalpy") self.modelEnergy.addItem(self.tr("Temperature"), "temperature") self.modelEnergy.addItem(self.tr("Saturation enthalpy"), "hsat_P") if int(self.currentid) > 0: if ThermodynamicsModel(self.case).getMaterials(self.currentid) == 'user_material' : self.modelEnergy.disableItem(1) self.modelEnergy.disableItem(2) self.modelNonCondensable = ComboModel(self.comboBoxNonCondensable, 1, 1) self.currentNonCond = "" self.currentNonCondLabel = "" self.modelScalar = ComboModel(self.comboBoxScalar, 1, 1) self.currentScalar = "" self.currentScalarLabel = "" # hide groupBoxEnergy, groupBoxNonCondensable self.labelEnergy.hide() self.comboBoxEnergy.hide() self.pushButtonEnergy.hide() self.labelNonCondensable.hide() self.comboBoxNonCondensable.hide() self.pushButtonNonCondensable.hide() self.labelScalar.hide() self.comboBoxScalar.hide() self.pushButtonScalar.hide() # Connect signals to slots self.comboBoxVolumeZone.activated[str].connect(self.slotVolumeZone) self.comboBoxField.activated[str].connect(self.slotField) self.comboBoxEnergy.activated[str].connect(self.slotEnergyModel) self.comboBoxNonCondensable.activated[str].connect(self.slotNonCondensableType) self.comboBoxScalar.activated[str].connect(self.slotScalarName) self.pushButtonPressure.clicked.connect(self.slotPressure) self.pushButtonVelocity.clicked.connect(self.slotVelocity) self.pushButtonFraction.clicked.connect(self.slotFraction) self.pushButtonEnergy.clicked.connect(self.slotEnergy) self.pushButtonNonCondensable.clicked.connect(self.slotNonCondensable) self.pushButtonScalar.clicked.connect(self.slotScalar) exp = self.mdl.getFormulaPressure(self.zone) if exp: self.pushButtonPressure.setStyleSheet("background-color: green") self.pushButtonPressure.setToolTip(exp) else: self.pushButtonPressure.setStyleSheet("background-color: red") if (len(self.mdl.getFieldIdList()) > 0): self.groupBoxDefinition.show() self.initializeVariables(self.zone, self.currentid) exp = self.mdl.getFormula(self.zone, self.currentid, 'velocity') if exp: self.pushButtonVelocity.setStyleSheet("background-color: green") self.pushButtonVelocity.setToolTip(exp) else: self.pushButtonVelocity.setStyleSheet("background-color: red") exp = self.mdl.getFormula(self.zone, self.currentid, 'volume_fraction') if exp: self.pushButtonFraction.setStyleSheet("background-color: green") self.pushButtonFraction.setToolTip(exp) else: self.pushButtonFraction.setStyleSheet("background-color: red") if self.mdl.getEnergyResolution(self.currentid) == "on": exp = self.mdl.getFormula(self.zone, self.currentid, 'enthalpy') if exp: self.pushButtonEnergy.setStyleSheet("background-color: green") self.pushButtonEnergy.setToolTip(exp) else: self.pushButtonEnergy.setStyleSheet("background-color: red") lst = self.NonCondensable.getNonCondensableByFieldId(self.currentid) if len(lst) > 0 : exp = self.mdl.getFormulaNonCondensable(self.zone, self.currentid, self.currentNonCond) if exp: self.pushButtonNonCondensable.setStyleSheet("background-color: green") self.pushButtonNonCondensable.setToolTip(exp) else: self.pushButtonNonCondensable.setStyleSheet("background-color: red") lst = self.SpeciesModel.getScalarByFieldId(self.currentid) if len(lst) > 0 : exp = self.mdl.getFormulaScalar(self.zone, self.currentid, self.currentScalar) if exp: self.pushButtonScalar.setStyleSheet("background-color: green") self.pushButtonScalar.setToolTip(exp) else: self.pushButtonScalar.setStyleSheet("background-color: red") else : self.groupBoxDefinition.hide() self.case.undoStartGlobal()
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 TimeStepView(QWidget, Ui_TimeStepForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_TimeStepForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = TimeStepModel(self.case) # Combo model self.modelTimeOptions = ComboModel(self.comboBoxOptions,2,1) self.modelTimeOptions.addItem(self.tr("Constant"), '0') self.modelTimeOptions.addItem(self.tr("Variable"), '1') # Connections self.connect(self.comboBoxOptions, SIGNAL("activated(const QString&)"), self.slotTimePassing) self.connect(self.lineEditDTREF, SIGNAL("textChanged(const QString &)"), self.slotTimeStep) self.connect(self.lineEditNTMABS, SIGNAL("textChanged(const QString &)"), self.slotIter) self.connect(self.lineEditCOUMAX, SIGNAL("textChanged(const QString &)"), self.slotTimeOptionCOUMAX) self.connect(self.lineEditFOUMAX, SIGNAL("textChanged(const QString &)"), self.slotTimeOptionFOUMAX) self.connect(self.lineEditCDTMIN, SIGNAL("textChanged(const QString &)"), self.slotTimeOptionCDTMIN) self.connect(self.lineEditCDTMAX, SIGNAL("textChanged(const QString &)"), self.slotTimeOptionCDTMAX) self.connect(self.lineEditVARRDT, SIGNAL("textChanged(const QString &)"), self.slotTimeOptionVARRDT) self.connect(self.checkBoxIPTLRO, SIGNAL("clicked()"), self.slotThermalTimeStep) self.connect(self.checkBoxINPDT0, SIGNAL("clicked()"), self.slotZeroTimeStep) # Validators validatorDTREF = DoubleValidator(self.lineEditDTREF, min=0.0) validatorDTREF.setExclusiveMin(True) validatorNTMABS = IntValidator(self.lineEditNTMABS, min=1) validatorCOUMAX = DoubleValidator(self.lineEditCOUMAX, min=0.0) validatorCOUMAX.setExclusiveMin(True) validatorFOUMAX = DoubleValidator(self.lineEditFOUMAX, min=0.0) validatorFOUMAX.setExclusiveMin(True) validatorCDTMIN = DoubleValidator(self.lineEditCDTMIN, min=0.0, max=1.0) validatorCDTMIN.setExclusiveMin(True) validatorCDTMAX = DoubleValidator(self.lineEditCDTMAX, min=1.0) validatorVARRDT = DoubleValidator(self.lineEditVARRDT, min=0.0, max=1.0) validatorVARRDT.setExclusiveMin(True) self.lineEditDTREF.setValidator(validatorDTREF) self.lineEditNTMABS.setValidator(validatorNTMABS) self.lineEditCOUMAX.setValidator(validatorCOUMAX) self.lineEditFOUMAX.setValidator(validatorFOUMAX) self.lineEditCDTMIN.setValidator(validatorCDTMIN) self.lineEditCDTMAX.setValidator(validatorCDTMAX) self.lineEditVARRDT.setValidator(validatorVARRDT) # Initialization status = SteadyManagementModel(self.case).getSteadyFlowManagement() if status == 'on': self.comboBoxOptions.hide() self.mdl.setTimePassing(2) courant_max = self.mdl.getOptions('max_courant_num') fourier_max = self.mdl.getOptions('max_fourier_num') time_step_min_factor = self.mdl.getOptions('time_step_min_factor') time_step_max_factor = self.mdl.getOptions('time_step_max_factor') time_step_var = self.mdl.getOptions('time_step_var') self.lineEditCOUMAX.setText(str(courant_max)) self.lineEditFOUMAX.setText(str(fourier_max)) self.lineEditCDTMIN.setText(str(time_step_min_factor)) self.lineEditCDTMAX.setText(str(time_step_max_factor)) self.lineEditVARRDT.setText(str(time_step_var)) self.groupBoxLabels.show() else: self.comboBoxOptions.show() idtvar = self.mdl.getTimePassing() self.modelTimeOptions.setItem(str_model=str(idtvar)) from code_saturne.Pages.TurbulenceModel import TurbulenceModel model = TurbulenceModel(self.case).getTurbulenceModel() del TurbulenceModel if model in ('LES_Smagorinsky', 'LES_dynamique', 'LES_WALE'): idtvar = 0 self.modelTimeOptions.setItem(str_model=str(idtvar)) self.modelTimeOptions.disableItem(str_model='0') self.modelTimeOptions.disableItem(str_model='1') text = self.comboBoxOptions.currentText() self.slotTimePassing(text) dtref = self.mdl.getTimeStep() self.lineEditDTREF.setText(str(dtref)) ntmabs = self.mdl.getIterationsNumber() self.lineEditNTMABS.setText(str(ntmabs)) if self.mdl.thermalCase(): if self.mdl.getThermalTimeStep() == 'on': self.checkBoxIPTLRO.setChecked(True) else: self.checkBoxIPTLRO.setChecked(False) else: self.lineIPTLRO.hide() self.labelIPTLRO.hide() self.checkBoxIPTLRO.hide() self.mdl.RemoveThermalTimeStepNode() if self.mdl.getZeroTimeStep() == 'on': self.checkBoxINPDT0.setChecked(True) else: self.checkBoxINPDT0.setChecked(False) self.case.undoStartGlobal() @pyqtSignature("") def slotTimePassing(self, text): """ Input IDTVAR. """ idtvar = int(self.modelTimeOptions.dicoV2M[str(text)]) self.mdl.setTimePassing(idtvar) if idtvar in (1, 2): courant_max = self.mdl.getOptions('max_courant_num') fourier_max = self.mdl.getOptions('max_fourier_num') time_step_min_factor = self.mdl.getOptions('time_step_min_factor') time_step_max_factor = self.mdl.getOptions('time_step_max_factor') time_step_var = self.mdl.getOptions('time_step_var') self.lineEditCOUMAX.setText(str(courant_max)) self.lineEditFOUMAX.setText(str(fourier_max)) self.lineEditCDTMIN.setText(str(time_step_min_factor)) self.lineEditCDTMAX.setText(str(time_step_max_factor)) self.lineEditVARRDT.setText(str(time_step_var)) self.groupBoxLabels.show() else: self.groupBoxLabels.hide() @pyqtSignature("const QString &") def slotTimeStep(self, text): """ Input DTREF. """ if self.sender().validator().state == QValidator.Acceptable: time_step = from_qvariant(text, float) self.mdl.setTimeStep(time_step) @pyqtSignature("const QString &") def slotIter(self, text): """ Input NTMABS. """ if self.sender().validator().state == QValidator.Acceptable: iteration = from_qvariant(text, int) self.mdl.setIterationsNumber(iteration) @pyqtSignature("const QString &") def slotTimeOptionCOUMAX(self, text): """ Input COUMAX. """ if self.sender().validator().state == QValidator.Acceptable: courant_max = from_qvariant(text, float) self.mdl.setOptions('max_courant_num', courant_max) @pyqtSignature("const QString &") def slotTimeOptionFOUMAX(self, text): """ Input FOUMAX. """ if self.sender().validator().state == QValidator.Acceptable: fourier_max = from_qvariant(text, float) self.mdl.setOptions('max_fourier_num', fourier_max) @pyqtSignature("const QString &") def slotTimeOptionCDTMIN(self, text): """ Input CDTMIN. """ if self.sender().validator().state == QValidator.Acceptable: time_step_min_factor = from_qvariant(text, float) self.mdl.setOptions('time_step_min_factor', time_step_min_factor) @pyqtSignature("const QString &") def slotTimeOptionCDTMAX(self, text): """ Input CDTMAX. """ if self.sender().validator().state == QValidator.Acceptable: time_step_max_factor = from_qvariant(text, float) self.mdl.setOptions('time_step_max_factor', time_step_max_factor) @pyqtSignature("const QString &") def slotTimeOptionVARRDT(self, text): """ Input VARRDT. """ if self.sender().validator().state == QValidator.Acceptable: time_step_var = from_qvariant(text, float) self.mdl.setOptions('time_step_var', time_step_var) @pyqtSignature("") def slotThermalTimeStep(self): """ Input IPTLRO. """ if self.checkBoxIPTLRO.isChecked(): self.mdl.setThermalTimeStep("on") else: self.mdl.setThermalTimeStep("off") @pyqtSignature("") def slotZeroTimeStep(self): """ Input INPDT0. """ if self.checkBoxINPDT0.isChecked(): self.mdl.setZeroTimeStep("on") else: self.mdl.setZeroTimeStep("off") def tr(self, text): """ Translation """ return text
class BoundaryConditionsElectricalView(QWidget, Ui_BoundaryConditionsElectricalForm): """ Boundary condifition for the velocity part """ def __init__(self, parent): """ Constructor. """ QWidget.__init__(self, parent) Ui_BoundaryConditionsElectricalForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget. """ self.__case = case self.__boundary = None self.__model = ElectricalModel(self.__case) self.species_list = [] self.notebook = NotebookModel(self.__case) self.lineEditValuePotElec.textChanged[str].connect(self.slotPotElec) self.lineEditValuePotElecIm.textChanged[str].connect(self.slotPotElecIm) self.lineEditValueSpecies.textChanged[str].connect(self.slotSpecies) self.pushButtonPotVectorFormula.clicked.connect(self.slotPotVectorFormula) self.comboBoxTypePotElec.activated[str].connect(self.slotPotElecChoice) self.comboBoxTypePotElecIm.activated[str].connect(self.slotPotElecImChoice) self.comboBoxTypePotVector.activated[str].connect(self.slotPotVectorChoice) self.comboBoxSpecies.activated[str].connect(self.slotSpeciesChoice) self.comboBoxPotVector.activated[str].connect(self.slotPotVectorComponentChoice) ## Validators validatorPotElec = DoubleValidator(self.lineEditValuePotElec) validatorPotElecIm = DoubleValidator(self.lineEditValuePotElecIm) validatorSpecies = DoubleValidator(self.lineEditValueSpecies, min=0.) self.lineEditValuePotElec.setValidator(validatorPotElec) self.lineEditValuePotElecIm.setValidator(validatorPotElecIm) self.lineEditValueSpecies.setValidator(validatorSpecies) def __setBoundary(self, boundary): """ Set the current boundary """ self.__boundary = boundary self.nature = boundary.getNature() self.groupBoxPotElecIm.hide() self.groupBoxPotVector.hide() self.groupBoxMixture.hide() self.modelPotElec = ComboModel(self.comboBoxTypePotElec, 1, 1) self.modelPotElecIm = ComboModel(self.comboBoxTypePotElecIm, 1, 1) self.modelPotVector = ComboModel(self.comboBoxTypePotVector, 1, 1) self.modelPotElec.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelPotElec.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotElec.addItem(self.tr("Prescribed flux"), 'neumann') self.modelPotElec.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') if self.__model.getScaling() == 'on': self.modelPotElec.addItem(self.tr("Implicit value (dpot)"), 'dirichlet_implicit') #TODO self.modelPotElec.disableItem(1) self.modelPotElec.disableItem(3) self.potElec = "elec_pot_r" self.modelPotElecLabel = ComboModel(self.comboBoxPotElec,1,1) self.modelPotElecLabel.addItem(self.tr(self.potElec),self.potElec) self.modelPotElecLabel.setItem(str_model = self.potElec) self.modelPotElecIm.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelPotElecIm.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotElecIm.addItem(self.tr("Prescribed flux"), 'neumann') self.modelPotElecIm.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') #TODO self.modelPotElecIm.disableItem(1) self.modelPotElecIm.disableItem(3) self.potElecIm = 'elec_pot_i' self.modelPotElecImLabel = ComboModel(self.comboBoxPotElecIm,1,1) self.modelPotElecImLabel.addItem(self.tr(self.potElecIm),self.potElecIm) self.modelPotElecImLabel.setItem(str_model = self.potElecIm) self.modelPotVector.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotVector.addItem(self.tr("Null flux"), 'neumann') self.modelPotVector.addItem(self.tr("Implicit flux"), 'neumann_implicit') self.modelPotVector.disableItem(0) self.potVect = 'vec_potential' self.modelPotVectLabel = ComboModel(self.comboBoxPotVector, 1, 1) self.modelPotVectLabel.addItem(self.tr('vec_potential'), 'vec_potential') self.modelPotVectLabel.setItem(str_model = self.potVect) if self.__model.getElectricalModel() == 'joule': if self.__model.getJouleModel() == 'three-phase' or \ self.__model.getJouleModel() == 'three-phase+Transformer': self.groupBoxPotElecIm.show() elif self.__model.getElectricalModel() == 'arc': self.groupBoxPotVector.show() self.species = "" if self.nature == 'inlet': if self.__model.getGasNumber() > 1: self.groupBoxMixture.show() self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.species_list = self.__model.getSpeciesLabelsList() for species in self.species_list: self.modelSpecies.addItem(self.tr(species), species) self.species = self.species_list[0] self.modelSpecies.setItem(str_model = self.species) self.initializeVariables() def initializeVariables(self): """ Initialize widget """ self.lineEditValuePotElec.hide() self.lineEditValuePotElecIm.hide() self.lineEditValuePotVector.hide() self.labelValuePotVector.hide() self.labelValuePotElec.hide() self.labelValuePotElecIm.hide() self.pushButtonPotVectorFormula.setEnabled(False) self.pushButtonPotVectorFormula.setStyleSheet("background-color: None") self.pushButtonPotElecFormula.setEnabled(False) self.pushButtonPotElecFormula.setStyleSheet("background-color: None") self.pushButtonPotElecImFormula.setEnabled(False) self.pushButtonPotElecImFormula.setStyleSheet("background-color: None") # Initialize electric potential self.potElec_type = self.__b.getElecScalarChoice(self.potElec) self.modelPotElec.setItem(str_model = self.potElec_type) if self.potElec_type == 'dirichlet' or self.potElec_type == 'neumann': self.lineEditValuePotElec.show() self.labelValuePotElec.show() v = self.__b.getElecScalarValue(self.potElec, self.potElec_type) self.lineEditValuePotElec.setText(str(v)) # Initialize imaginary electric potential if self.__model.getElectricalModel() == 'joule': if self.__model.getJouleModel() == 'three-phase' or \ self.__model.getJouleModel() == 'three-phase+Transformer': self.potElecIm_type = self.__b.getElecScalarChoice(self.potElecIm) self.modelPotElecIm.setItem(str_model = self.potElecIm_type) if self.potElecIm_type == 'dirichlet' or self.potElecIm_type == 'neumann': self.lineEditValuePotElecIm.show() self.labelValuePotElecIm.show() v = self.__b.getElecScalarValue(self.potElecIm, self.potElecIm_type) self.lineEditValuePotElecIm.setText(str(v)) # Initialize potential vector if self.__model.getElectricalModel() == 'arc': self.potVec_type = self.__b.getPotentialVectorChoice(self.potVect) self.modelPotVector.setItem(str_model = self.potVec_type) if self.potVec_type == 'dirichlet_formula': self.pushButtonPotVectorFormula.setEnabled(True) exp = self.__b.getElecScalarFormula(self.potVect, self.potVec_type) if exp: self.pushButtonPotVectorFormula.setStyleSheet("background-color: green") self.pushButtonPotVectorFormula.setToolTip(exp) else: self.pushButtonPotVectorFormula.setStyleSheet("background-color: red") # Initialize species if self.species : v = self.__b.getElecScalarValue(self.species, 'dirichlet') self.lineEditValueSpecies.setText(str(v)) @pyqtSlot(str) def slotPotElecChoice(self, text): """ INPUT choice for electric potential type """ potElec_type = self.modelPotElec.dicoV2M[str(text)] self.__b.setElecScalarChoice(self.potElec, potElec_type) self.initializeVariables() @pyqtSlot(str) def slotPotElecImChoice(self, text): """ INPUT choice for imaginary electric potential type """ potElecIm_type = self.modelPotElecIm.dicoV2M[str(text)] self.__b.setElecScalarChoice(self.potElecIm, potElecIm_type) self.initializeVariables() @pyqtSlot(str) def slotPotVectorChoice(self, text): """ INPUT choice for potential vector type """ potVec_choice = self.modelPotVector.dicoV2M[str(text)] self.__b.setPotentialVectorChoice(self.potVect, potVec_choice) self.initializeVariables() @pyqtSlot(str) def slotSpeciesChoice(self, text): """ INPUT species choice """ self.species = self.modelSpecies.dicoV2M[str(text)] self.initializeVariables() @pyqtSlot(str) def slotPotVectorComponentChoice(self, text): """ INPUT potential vector component choice """ self.potVect = self.modelPotVectLabel.dicoV2M[str(text)] self.initializeVariables() @pyqtSlot(str) def slotPotElec(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.potElec, self.potElec_type, value) @pyqtSlot(str) def slotPotElecIm(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.potElecIm, self.potElecIm_type, value) @pyqtSlot(str) def slotSpecies(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.species, 'dirichlet', value) @pyqtSlot() def slotPotVectorFormula(self): """ """ exp = self.__b.getElecScalarFormula(self.potVect, self.potVec_type) exa = """#example: """ if not exp: exp = self.potVect + "[0] = 0;\n" + \ self.potVect + "[1] = 0;\n" + \ self.potVect + "[2] = 0;\n" req = [(self.potVect + "[0]", 'vector potential X'), (self.potVect + "[1]", 'vector potential Y'), (self.potVect + "[2]", 'vector potential Z')] sym = [('x', "X cell's gravity center"), ('y', "Y cell's gravity center"), ('z', "Z cell's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMeiEditorView(self,expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotPotVectorFormula -> %s" % str(result)) self.__b.setElecScalarFormula(self.potVect, self.potVec_type, str(result)) self.pushButtonPotVectorFormula.setToolTip(result) self.pushButtonPotVectorFormula.setStyleSheet("background-color: green") def showWidget(self, b): """ Show the widget. """ self.__b = b if self.__model.getElectricalModel() != 'off': label = b.getLabel() nature = "joule_" + b.getNature() self.__b = Boundary(nature, label, self.__case) self.__setBoundary(b) self.show() else: self.hideWidget() def hideWidget(self): """ Hide all. """ self.hide() def tr(self, text): """ Translation. """ 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 LagrangianView(QWidget, Ui_LagrangianForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = LagrangianModel(self.case) # Combo model self.modelIILAGR = ComboModel(self.comboBoxIILAGR,3,1) self.modelIILAGR.addItem(self.tr("One-way coupling"), "one_way") self.modelIILAGR.addItem(self.tr("Two-way coupling"), "two_way") self.modelIILAGR.addItem(self.tr("Frozen carrier flow"), "frozen") self.modelIPHYLA = ComboModel(self.comboBoxIPHYLA,2,1) self.modelIPHYLA.addItem(self.tr("No model"), 'off') self.modelIPHYLA.addItem(self.tr("Heat transfer and evaporation"), 'thermal') self.modelIPHYLA.addItem(self.tr("Pulverised coal model"), 'coal') # Connections self.connect(self.comboBoxIILAGR, SIGNAL("activated(const QString&)"), self.slotIILAGR) self.connect(self.checkBoxISUILA, SIGNAL("clicked()"), self.slotISUILA) self.connect(self.checkBoxISTTIO, SIGNAL("clicked()"), self.slotISTTIO) self.connect(self.checkBoxINJCON, SIGNAL("clicked()"), self.slotINJCON) self.connect(self.checkBoxIDEPST, SIGNAL("clicked()"), self.slotIDEPST) self.connect(self.comboBoxIPHYLA, SIGNAL("activated(const QString&)"), self.slotIPHYLA) self.connect(self.checkBoxITPVAR, SIGNAL("clicked()"), self.slotITPVAR) self.connect(self.checkBoxIMPVAR, SIGNAL("clicked()"), self.slotIMPVAR) self.connect(self.checkBoxIENCRA, SIGNAL("clicked()"), self.slotIENCRA) # self.connect(self.lineEditNSTITS, SIGNAL("textChanged(const QString &)"), self.slotNSTITS) self.connect(self.checkBoxLTSDYN, SIGNAL("clicked()"), self.slotLTSDYN) self.connect(self.checkBoxLTSMAS, SIGNAL("clicked()"), self.slotLTSMAS) self.connect(self.checkBoxLTSTHE, SIGNAL("clicked()"), self.slotLTSTHE) self.connect(self.toolButtonAdvanced, SIGNAL("clicked()"), self.slotAdvancedOptions) # Validators validatorNSTITS = IntValidator(self.lineEditNSTITS) self.lineEditNSTITS.setValidator(validatorNSTITS) # initialize Widgets # # Update the lagrangian list with the calculation features # # for mdl in self.model.lagrangianCouplingMode(): # if mdl not in self.model.lagrangianStatus(): # self.modelIILAGR.disableItem(str_model=mdl) from code_saturne.Pages.CoalCombustionModel import CoalCombustionModel if CoalCombustionModel(self.case).getCoalCombustionModel() != 'off': self.modelIILAGR.disableItem(str_model="one_way") self.modelIILAGR.disableItem(str_model="two_way") del CoalCombustionModel model = self.model.getCouplingMode() self.modelIILAGR.setItem(str_model=model) self.slotIILAGR(self.modelIILAGR.dicoM2V[model]) status = self.model.getRestart() if status == "on": self.checkBoxISUILA.setChecked(True) else: self.checkBoxISUILA.setChecked(False) status = self.model.getCarrierFlowStationary() if status == "on": self.checkBoxISTTIO.setChecked(True) else: self.checkBoxISTTIO.setChecked(False) status = self.model.getContinuousInjection() if status == "on": self.checkBoxINJCON.setChecked(True) else: self.checkBoxINJCON.setChecked(False) status = self.model.getDepositionSubmodel() if status == "on": self.checkBoxIDEPST.setChecked(True) else: self.checkBoxIDEPST.setChecked(False) if ( model == "frozen" ): self.labelISTTIO.setDisabled(True) self.checkBoxISTTIO.setChecked(True) self.checkBoxISTTIO.setDisabled(True) status = self.model.getContinuousInjection() if status == "on": self.checkBoxINJCON.setChecked(True) else: self.checkBoxINJCON.setChecked(False) part_model = self.model.getParticlesModel() self.modelIPHYLA.setItem(str_model=part_model) self.slotIPHYLA(self.modelIPHYLA.dicoM2V[part_model]) self.case.undoStartGlobal() @pyqtSignature("const QString&") def slotIILAGR(self, text): """ Input IILAGR. """ model = self.modelIILAGR.dicoV2M[str(text)] self.model.setCouplingMode(model) self.groupBox2way.hide() self.labelISTTIO.setDisabled(False) self.checkBoxISTTIO.setDisabled(False) if model == "one_way": pass elif model == "two_way": self.groupBox2way.show() start_it = self.model.get2WayCouplingStartIteration() self.lineEditNSTITS.setText(str(start_it)) status = self.model.get2WayCouplingDynamic() if status == "on": self.checkBoxLTSDYN.setChecked(True) else: self.checkBoxLTSDYN.setChecked(False) status = self.model.get2WayCouplingMass() if status == "on": self.checkBoxLTSMAS.setChecked(True) else: self.checkBoxLTSMAS.setChecked(False) status = self.model.get2WayCouplingTemperature() if status == "on": self.checkBoxLTSTHE.setChecked(True) else: self.checkBoxLTSTHE.setChecked(False) elif model == "frozen": self.labelISTTIO.setDisabled(True) self.checkBoxISTTIO.setDisabled(True) @pyqtSignature("") def slotISUILA(self): """ Input ISUILA. """ if self.checkBoxISUILA.isChecked(): self.model.setRestart("on") else: self.model.setRestart("off") @pyqtSignature("") def slotISTTIO(self): """ Input ISTTIO. """ if self.checkBoxISTTIO.isChecked(): self.model.setCarrierFlowStationary("on") else: self.model.setCarrierFlowStationary("off") @pyqtSignature("") def slotINJCON(self): """ Input INJCON. """ if self.checkBoxINJCON.isChecked(): self.model.setContinuousInjection("on") else: self.model.setContinuousInjection("off") @pyqtSignature("") def slotIDEPST(self): """ Input IDEPST. """ if self.checkBoxIDEPST.isChecked(): self.model.setDepositionSubmodel("on") else: self.model.setDepositionSubmodel("off") @pyqtSignature("const QString&") def slotIPHYLA(self, text): """ Input IPHYLA. """ value = self.modelIPHYLA.dicoV2M[str(text)] self.model.setParticlesModel(value) self.frameModel1.hide() self.frameModel2.hide() # No model if value == "off": pass # Equations on temperature, diameter and mass elif value == "thermal": self.frameModel1.show() status = self.model.getHeating() if status == "on": self.checkBoxITPVAR.setChecked(True) else: self.checkBoxITPVAR.setChecked(False) status = self.model.getEvaporation() if status == "on": self.checkBoxIMPVAR.setChecked(True) else: self.checkBoxIMPVAR.setChecked(False) # Pulverised coal model elif value == "coal": self.frameModel2.show() self.tableViewCoals.show() status = self.model.getCoalFouling() if status == "on": self.checkBoxIENCRA.setChecked(True) else: self.checkBoxIENCRA.setChecked(False) self.slotIENCRA() @pyqtSignature("") def slotITPVAR(self): """ Input ITPVAR. """ if self.checkBoxITPVAR.isChecked(): self.model.setHeating("on") else: self.model.setHeating("off") @pyqtSignature("") def slotIMPVAR(self): """ Input IMPVAR. """ if self.checkBoxIMPVAR.isChecked(): self.model.setEvaporation("on") else: self.model.setEvaporation("off") @pyqtSignature("") def slotIENCRA(self): """ Input IENCRA. """ if self.checkBoxIENCRA.isChecked(): self.model.setCoalFouling("on") self.modelCoals = StandardItemModelCoals(self.case, self.model) self.tableViewCoals.setModel(self.modelCoals) delegateValue = ValueDelegate(self.tableViewCoals) delegateValue2 = ValueDelegate(self.tableViewCoals) delegateLabel = LabelDelegate(self.tableViewCoals) self.tableViewCoals.setItemDelegateForColumn(0, delegateLabel) self.tableViewCoals.setItemDelegateForColumn(1, delegateValue) self.tableViewCoals.setItemDelegateForColumn(2, delegateValue) self.tableViewCoals.setItemDelegateForColumn(3, delegateValue2) self.tableViewCoals.setItemDelegateForColumn(4, delegateValue2) self.tableViewCoals.show() self.tableViewCoals.verticalHeader().setResizeMode(QHeaderView.ResizeToContents) self.tableViewCoals.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) self.tableViewCoals.horizontalHeader().setResizeMode(0, QHeaderView.Stretch) else: self.model.setCoalFouling("off") if hasattr(self, "modelCoals"): del self.modelCoals self.tableViewCoals.hide() @pyqtSignature("const QString&") def slotNSTITS(self, text): """ Input NSTITS. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.set2WayCouplingStartIteration(value) @pyqtSignature("") def slotLTSDYN(self): """ Input LTSDYN. """ if self.checkBoxLTSDYN.isChecked(): self.model.set2WayCouplingDynamic("on") else: self.model.set2WayCouplingDynamic("off") @pyqtSignature("") def slotLTSMAS(self): """ Input LTSMAS. """ if self.checkBoxLTSMAS.isChecked(): self.model.set2WayCouplingMass("on") else: self.model.set2WayCouplingMass("off") @pyqtSignature("") def slotLTSTHE(self): """ Input LTSTHE. """ if self.checkBoxLTSTHE.isChecked(): self.model.set2WayCouplingTemperature("on") else: self.model.set2WayCouplingTemperature("off") @pyqtSignature("") def slotAdvancedOptions(self): """ Ask one popup for advanced specifications """ default = {} default['scheme_order'] = self.model.getSchemeOrder() default['turbulent_dispertion'] = self.model.getTurbulentDispersion() default['fluid_particles_turbulent_diffusion'] = self.model.getTurbulentDiffusion() default['complete_model_iteration'] = self.model.getCompleteModelStartIteration() default['complete_model_direction'] = self.model.getCompleteModelDirection() dialog = LagrangianAdvancedOptionsDialogView(self, self.case, default) if dialog.exec_(): result = dialog.get_result() self.model.setSchemeOrder(int(result['scheme_order'])) self.model.setTurbulentDispersion(result['turbulent_dispertion']) self.model.setTurbulentDiffusion(result['fluid_particles_turbulent_diffusion']) self.model.setCompleteModelStartIteration(result['complete_model_iteration']) self.model.setCompleteModelDirection(int(result['complete_model_direction'])) def tr(self, text): """ Translation """ return text
class NucleateBoilingView(QWidget, Ui_NucleateBoiling): """ Nucleate boiling model layout. """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_NucleateBoiling.__init__(self) self.setupUi(self) def setup(self, case): self.case = case self.case.undoStopGlobal() self.mdl = NucleateBoilingModel(self.case) self.modelHeatTransferModel = ComboModel(self.comboBoxHeatTransferModel, 2, 1) self.modelHeatTransferModel.addItem(self.tr("Extended Kurul-Podowski model"), "extended_kurul-podowski") self.modelHeatTransferModel.addItem(self.tr("Standard Kurul-Podowski model"), "standard_kurul-podowski") self.modelWallFunctionModel = ComboModel(self.comboBoxWallFunctionModel, 3, 1) self.modelWallFunctionModel.addItem(self.tr("standard (single phase wall function)"), "standard") self.modelWallFunctionModel.addItem(self.tr("Koncar Tiselj-NED 2008"), "koncar") self.modelWallFunctionModel.addItem(self.tr("Mimouni et al-NED 2008"), "mimouni") if InterfacialEnthalpyModel(self.case).getPoolBoiling() == "on": self.modelWallFunctionModel.disableItem(str_model="koncar") self.modelWallFunctionModel.disableItem(str_model="mimouni") self.modelYPlus = ComboModel(self.comboBoxYPlus, 3, 1) self.modelYPlus.addItem(self.tr("Boundary cell center"), "center") self.modelYPlus.addItem(self.tr("Y+ = "), "Yplus_value") self.modelYPlus.addItem(self.tr("Nucleate bubble diameter"), "diameter") # Validators validatorYplus = DoubleValidator(self.lineEditYPlus, min = 0.0) validatorRad = DoubleValidator(self.lineEditMaxRadius, min = 0.0) validatorDiam = DoubleValidator(self.lineEditMaxDiam, min = 0.0) validatorSat = DoubleValidator(self.lineEditMaxOverSaturation, min = 0.0) validatorLam = DoubleValidator(self.lineEditThermalConductivity, min = 0.0) validatorRho = DoubleValidator(self.lineEditDensity, min = 0.0) validatorCp = DoubleValidator(self.lineEditSpecificHeat, min = 0.0) validatorTh = DoubleValidator(self.lineEditThickness, min = 0.0) validatorYplus.setExclusiveMin(True) validatorRad.setExclusiveMin(True) validatorDiam.setExclusiveMin(True) validatorSat.setExclusiveMin(True) validatorLam.setExclusiveMin(True) validatorRho.setExclusiveMin(True) validatorCp.setExclusiveMin(True) validatorTh.setExclusiveMin(True) self.lineEditYPlus.setValidator(validatorYplus) self.lineEditMaxRadius.setValidator(validatorRad) self.lineEditMaxDiam.setValidator(validatorDiam) self.lineEditMaxOverSaturation.setValidator(validatorSat) self.lineEditThermalConductivity.setValidator(validatorLam) self.lineEditDensity.setValidator(validatorRho) self.lineEditSpecificHeat.setValidator(validatorCp) self.lineEditThickness.setValidator(validatorTh) # Connect signals to slots self.comboBoxHeatTransferModel.activated[str].connect(self.slotHeatTransferModel) self.comboBoxWallFunctionModel.activated[str].connect(self.slotWallFunctionModel) self.comboBoxYPlus.activated[str].connect(self.slotYPlus) self.checkBoxThickness.clicked.connect(self.slotThickness) self.lineEditYPlus.textChanged[str].connect(self.slotYPlusValue) self.lineEditMaxRadius.textChanged[str].connect(self.slotMaxRadius) self.lineEditMaxDiam.textChanged[str].connect(self.slotMaxDiam) self.lineEditMaxOverSaturation.textChanged[str].connect(self.slotMaxOverSaturation) self.lineEditThermalConductivity.textChanged[str].connect(self.slotThermalConductivity) self.lineEditDensity.textChanged[str].connect(self.slotDensity) self.lineEditSpecificHeat.textChanged[str].connect(self.slotSpecificHeat) self.lineEditThickness.textChanged[str].connect(self.slotThicknessValue) # load values isYPlus = self.mdl.getYPlusModel() self.modelYPlus.setItem(str_model=isYPlus) if isYPlus == "Yplus_value" : self.lineEditYPlus.show() self.lineEditYPlus.setText(str(self.mdl.getYPlusValue())) else : self.lineEditYPlus.hide() self.lineEditMaxRadius.setText(str(self.mdl.getMaxRadius())) self.lineEditMaxDiam.setText(str(self.mdl.getMaxDiameter())) self.lineEditMaxOverSaturation.setText(str(self.mdl.getMaxOverSaturation())) self.lineEditThermalConductivity.setText(str(self.mdl.getThermalConductivity())) self.lineEditDensity.setText(str(self.mdl.getDensity())) self.lineEditSpecificHeat.setText(str(self.mdl.getSpecificHeat())) model = self.mdl.getHeatTransferModel() self.modelHeatTransferModel.setItem(str_model=model) if model == "standard_kurul-podowski" : self.labelMaxRadius.setEnabled(0) self.lineEditMaxRadius.setEnabled(0) self.labelMaxRadiusUnit.setEnabled(0) self.labelMaxDiam.setEnabled(0) self.lineEditMaxDiam.setEnabled(0) self.labelMaxDiamUnit.setEnabled(0) else : self.labelMaxRadius.setEnabled(1) self.lineEditMaxRadius.setEnabled(1) self.labelMaxRadiusUnit.setEnabled(1) self.labelMaxDiam.setEnabled(1) self.lineEditMaxDiam.setEnabled(1) self.labelMaxDiamUnit.setEnabled(1) isThickness = self.mdl.getThicknessStatus() == "on" self.checkBoxThickness.setChecked(isThickness) if isThickness : self.lineEditThickness.show() self.labelThickness1.show() self.labelThickness2.show() self.lineEditThickness.setText(str(self.mdl.getThicknessValue())) else : self.lineEditThickness.hide() self.labelThickness1.hide() self.labelThickness2.hide() model = self.mdl.getWallFunctionModel() self.modelWallFunctionModel.setItem(str_model=model) self.case.undoStartGlobal()
class TimeStepView(QWidget, Ui_TimeStepForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_TimeStepForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = TimeStepModel(self.case) # Combo model self.modelTimeOptions = ComboModel(self.comboBoxOptions, 4, 1) self.modelTimeOptions.addItem(self.tr("Constant"), '0') self.modelTimeOptions.addItem(self.tr("Time varying (adaptive)"), '1') self.modelTimeOptions.addItem( self.tr("Space & time varying (pseudo-steady)"), '2') self.modelTimeOptions.addItem(self.tr("Steady"), '-1') # Connections self.comboBoxOptions.activated[str].connect(self.slotTimePassing) self.lineEditDTREF.textChanged[str].connect(self.slotTimeStep) self.lineEditRELXST.textChanged[str].connect(self.slotRelaxCoef) self.lineEditNTMABS.textChanged[str].connect(self.slotIter) self.lineEditCOUMAX.textChanged[str].connect(self.slotTimeOptionCOUMAX) self.lineEditFOUMAX.textChanged[str].connect(self.slotTimeOptionFOUMAX) self.lineEditCDTMIN.textChanged[str].connect(self.slotTimeOptionCDTMIN) self.lineEditCDTMAX.textChanged[str].connect(self.slotTimeOptionCDTMAX) self.lineEditVARRDT.textChanged[str].connect(self.slotTimeOptionVARRDT) self.checkBoxIPTLRO.clicked.connect(self.slotThermalTimeStep) self.checkBoxINPDT0.clicked.connect(self.slotZeroTimeStep) # Validators validatorDTREF = DoubleValidator(self.lineEditDTREF, min=0.0) validatorDTREF.setExclusiveMin(True) validatorRELXST = DoubleValidator(self.lineEditRELXST, min=0.0, max=1.0) validatorRELXST.setExclusiveMin(True) validatorNTMABS = IntValidator(self.lineEditNTMABS, min=1) validatorCOUMAX = DoubleValidator(self.lineEditCOUMAX, min=0.0) validatorCOUMAX.setExclusiveMin(True) validatorFOUMAX = DoubleValidator(self.lineEditFOUMAX, min=0.0) validatorFOUMAX.setExclusiveMin(True) validatorCDTMIN = DoubleValidator(self.lineEditCDTMIN, min=0.0, max=1.0) validatorCDTMIN.setExclusiveMin(True) validatorCDTMAX = DoubleValidator(self.lineEditCDTMAX, min=1.0) validatorVARRDT = DoubleValidator(self.lineEditVARRDT, min=0.0, max=1.0) validatorVARRDT.setExclusiveMin(True) self.lineEditDTREF.setValidator(validatorDTREF) self.lineEditRELXST.setValidator(validatorRELXST) self.lineEditNTMABS.setValidator(validatorNTMABS) self.lineEditCOUMAX.setValidator(validatorCOUMAX) self.lineEditFOUMAX.setValidator(validatorFOUMAX) self.lineEditCDTMIN.setValidator(validatorCDTMIN) self.lineEditCDTMAX.setValidator(validatorCDTMAX) self.lineEditVARRDT.setValidator(validatorVARRDT) # Initialization idtvar = self.mdl.getTimePassing() idtvar_p = idtvar # Constraints on time step from Turbulence model from code_saturne.Pages.TurbulenceModel import TurbulenceModel model = TurbulenceModel(self.case).getTurbulenceModel() del TurbulenceModel if model in ('LES_Smagorinsky', 'LES_dynamique', 'LES_WALE'): idtvar = 0 self.modelTimeOptions.disableItem(str_model='1') self.modelTimeOptions.disableItem(str_model='2') self.modelTimeOptions.disableItem(str_model='-1') # Constraints on time step from Lagrangian model from code_saturne.Pages.LagrangianModel import LagrangianModel model = LagrangianModel(self.case).getLagrangianModel() if model in ['one_way', 'two_way']: if idtvar not in [0, 1]: idtvar = 0 self.modelTimeOptions.disableItem(str_model='2') self.modelTimeOptions.disableItem(str_model='-1') if model == 'two_way': idtvar = 0 self.modelTimeOptions.disableItem(str_model='1') # Constraints on time step from compressible model from code_saturne.Pages.CompressibleModel import CompressibleModel model = CompressibleModel(self.case).getCompressibleModel() if model != 'off': if idtvar not in [0, 1]: idtvar = 0 self.modelTimeOptions.disableItem(str_model='1') self.modelTimeOptions.disableItem(str_model='2') self.modelTimeOptions.disableItem(str_model='-1') # Constraints on time step from groundwater model from code_saturne.Pages.GroundwaterModel import GroundwaterModel model = GroundwaterModel(self.case).getGroundwaterModel() if model != 'off': if idtvar not in [0, 1]: idtvar = 0 self.modelTimeOptions.disableItem(str_model='1') self.modelTimeOptions.disableItem(str_model='2') self.modelTimeOptions.disableItem(str_model='-1') # Change time step option if required by model constraints if idtvar_p != idtvar: self.mdl.setTimePassing(idtvar) ntmabs = self.mdl.getIterationsNumber() self.lineEditNTMABS.setText(str(ntmabs)) if self.mdl.thermalCase(): if self.mdl.getThermalTimeStep() == 'on': self.checkBoxIPTLRO.setChecked(True) else: self.checkBoxIPTLRO.setChecked(False) else: self.lineIPTLRO.hide() self.labelIPTLRO.hide() self.checkBoxIPTLRO.hide() self.mdl.RemoveThermalTimeStepNode() if self.mdl.getZeroTimeStep() == 'on': self.checkBoxINPDT0.setChecked(True) else: self.checkBoxINPDT0.setChecked(False) self.__setTimePassingDisplay(idtvar) self.case.undoStartGlobal() def __setTimePassingDisplay(self, idtvar): """ Choices based on IDTVAR. """ self.modelTimeOptions.setItem(str_model=str(idtvar)) if idtvar == -1: self.labelRELXST.show() self.lineEditRELXST.show() self.labelDTREF.hide() self.labelDTREFunit.hide() self.lineEditDTREF.hide() relax_coef = self.mdl.getRelaxCoefficient() self.lineEditRELXST.setText(str(relax_coef)) else: self.labelRELXST.hide() self.lineEditRELXST.hide() self.labelDTREF.show() self.labelDTREFunit.show() self.lineEditDTREF.show() dtref = self.mdl.getTimeStep() self.lineEditDTREF.setText(str(dtref)) if idtvar in (1, 2): courant_max = self.mdl.getOptions('max_courant_num') fourier_max = self.mdl.getOptions('max_fourier_num') time_step_min_factor = self.mdl.getOptions('time_step_min_factor') time_step_max_factor = self.mdl.getOptions('time_step_max_factor') time_step_var = self.mdl.getOptions('time_step_var') self.lineEditCOUMAX.setText(str(courant_max)) self.lineEditFOUMAX.setText(str(fourier_max)) self.lineEditCDTMIN.setText(str(time_step_min_factor)) self.lineEditCDTMAX.setText(str(time_step_max_factor)) self.lineEditVARRDT.setText(str(time_step_var)) self.groupBoxLabels.show() else: self.groupBoxLabels.hide() @pyqtSlot(str) def slotTimePassing(self, text): """ Input IDTVAR. """ idtvar = int(self.modelTimeOptions.dicoV2M[str(text)]) self.mdl.setTimePassing(idtvar) self.__setTimePassingDisplay(idtvar) @pyqtSlot(str) def slotTimeStep(self, text): """ Input DTREF. """ if self.lineEditDTREF.validator().state == QValidator.Acceptable: time_step = from_qvariant(text, float) self.mdl.setTimeStep(time_step) @pyqtSlot(str) def slotRelaxCoef(self, text): """ Input relaxation coefficient. """ if self.lineEditRELXST.validator().state == QValidator.Acceptable: relax_coef = from_qvariant(text, float) self.mdl.setRelaxCoefficient(relax_coef) @pyqtSlot(str) def slotIter(self, text): """ Input NTMABS. """ if self.lineEditNTMABS.validator().state == QValidator.Acceptable: iteration = from_qvariant(text, int) self.mdl.setIterationsNumber(iteration) @pyqtSlot(str) def slotTimeOptionCOUMAX(self, text): """ Input COUMAX. """ if self.lineEditCOUMAX.validator().state == QValidator.Acceptable: courant_max = from_qvariant(text, float) self.mdl.setOptions('max_courant_num', courant_max) @pyqtSlot(str) def slotTimeOptionFOUMAX(self, text): """ Input FOUMAX. """ if self.lineEditFOUMAX.validator().state == QValidator.Acceptable: fourier_max = from_qvariant(text, float) self.mdl.setOptions('max_fourier_num', fourier_max) @pyqtSlot(str) def slotTimeOptionCDTMIN(self, text): """ Input CDTMIN. """ if self.lineEditCDTMIN.validator().state == QValidator.Acceptable: time_step_min_factor = from_qvariant(text, float) self.mdl.setOptions('time_step_min_factor', time_step_min_factor) @pyqtSlot(str) def slotTimeOptionCDTMAX(self, text): """ Input CDTMAX. """ if self.lineEditCDTMAX.validator().state == QValidator.Acceptable: time_step_max_factor = from_qvariant(text, float) self.mdl.setOptions('time_step_max_factor', time_step_max_factor) @pyqtSlot(str) def slotTimeOptionVARRDT(self, text): """ Input VARRDT. """ if self.lineEditVARRDT.validator().state == QValidator.Acceptable: time_step_var = from_qvariant(text, float) self.mdl.setOptions('time_step_var', time_step_var) @pyqtSlot() def slotThermalTimeStep(self): """ Input IPTLRO. """ if self.checkBoxIPTLRO.isChecked(): self.mdl.setThermalTimeStep("on") else: self.mdl.setThermalTimeStep("off") @pyqtSlot() def slotZeroTimeStep(self): """ Input INPDT0. """ if self.checkBoxINPDT0.isChecked(): self.mdl.setZeroTimeStep("on") else: self.mdl.setZeroTimeStep("off") def tr(self, text): """ Translation """ return text
class BoundaryConditionsElectricalView(QWidget, Ui_BoundaryConditionsElectricalForm): """ Boundary condifition for the velocity part """ def __init__(self, parent): """ Constructor. """ QWidget.__init__(self, parent) Ui_BoundaryConditionsElectricalForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget. """ self.__case = case self.__boundary = None self.__model = ElectricalModel(self.__case) self.species_list = [] self.connect(self.lineEditValuePotElec, SIGNAL("textChanged(const QString &)"), self.slotPotElec) self.connect(self.lineEditValuePotElecIm, SIGNAL("textChanged(const QString &)"), self.slotPotElecIm) self.connect(self.lineEditValueSpecies, SIGNAL("textChanged(const QString &)"), self.slotSpecies) self.connect(self.pushButtonPotVectorFormula, SIGNAL("clicked()"), self.slotPotVectorFormula) self.connect(self.comboBoxTypePotElec, SIGNAL("activated(const QString&)"), self.slotPotElecChoice) self.connect(self.comboBoxTypePotElecIm, SIGNAL("activated(const QString&)"), self.slotPotElecImChoice) self.connect(self.comboBoxTypePotVector, SIGNAL("activated(const QString&)"), self.slotPotVectorChoice) self.connect(self.comboBoxSpecies, SIGNAL("activated(const QString&)"), self.slotSpeciesChoice) self.connect(self.comboBoxPotVector, SIGNAL("activated(const QString&)"), self.slotPotVectorComponentChoice) ## Validators validatorPotElec = DoubleValidator(self.lineEditValuePotElec) validatorPotElecIm = DoubleValidator(self.lineEditValuePotElecIm) validatorSpecies = DoubleValidator(self.lineEditValueSpecies, min=0.) self.lineEditValuePotElec.setValidator(validatorPotElec) self.lineEditValuePotElecIm.setValidator(validatorPotElecIm) self.lineEditValueSpecies.setValidator(validatorSpecies) def __setBoundary(self, boundary): """ Set the current boundary """ self.__boundary = boundary self.nature = boundary.getNature() self.groupBoxPotElecIm.hide() self.groupBoxPotVector.hide() self.groupBoxMixture.hide() self.modelPotElec = ComboModel(self.comboBoxTypePotElec, 1, 1) self.modelPotElecIm = ComboModel(self.comboBoxTypePotElecIm, 1, 1) self.modelPotVector = ComboModel(self.comboBoxTypePotVector, 1, 1) self.modelPotElec.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelPotElec.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotElec.addItem(self.tr("Prescribed flux"), 'neumann') self.modelPotElec.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') if self.__model.getScaling() == 'on': self.modelPotElec.addItem(self.tr("Implicit value (dpot)"), 'dirichlet_implicit') #TODO self.modelPotElec.disableItem(1) self.modelPotElec.disableItem(3) self.potElec = "elec_pot_r" self.modelPotElecLabel = ComboModel(self.comboBoxPotElec,1,1) self.modelPotElecLabel.addItem(self.tr(self.potElec),self.potElec) self.modelPotElecLabel.setItem(str_model = self.potElec) self.modelPotElecIm.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelPotElecIm.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotElecIm.addItem(self.tr("Prescribed flux"), 'neumann') self.modelPotElecIm.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') #TODO self.modelPotElecIm.disableItem(1) self.modelPotElecIm.disableItem(3) self.potElecIm = 'elec_pot_i' self.modelPotElecImLabel = ComboModel(self.comboBoxPotElecIm,1,1) self.modelPotElecImLabel.addItem(self.tr(self.potElecIm),self.potElecIm) self.modelPotElecImLabel.setItem(str_model = self.potElecIm) self.modelPotVector.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotVector.addItem(self.tr("Null flux"), 'neumann') self.modelPotVector.addItem(self.tr("Implicit flux"), 'neumann_implicit') self.modelPotVector.disableItem(0) self.potVect = 'vec_potential_01' self.modelPotVectLabel = ComboModel(self.comboBoxPotVector, 3, 1) self.modelPotVectLabel.addItem(self.tr('vec_potential_01'), 'vec_potential_01') self.modelPotVectLabel.addItem(self.tr('vec_potential_02'), 'vec_potential_02') self.modelPotVectLabel.addItem(self.tr('vec_potential_03'), 'vec_potential_03') self.modelPotVectLabel.setItem(str_model = self.potVect) if self.__model.getElectricalModel() == 'joule': if self.__model.getJouleModel() == 'three-phase' or \ self.__model.getJouleModel() == 'three-phase+Transformer': self.groupBoxPotElecIm.show() elif self.__model.getElectricalModel() == 'arc': self.groupBoxPotVector.show() self.species = "" if self.nature == 'inlet': if self.__model.getGasNumber() > 1: self.groupBoxMixture.show() self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.species_list = self.__model.getSpeciesLabelsList() for species in self.species_list: self.modelSpecies.addItem(self.tr(species), species) self.species = self.species_list[0] self.modelSpecies.setItem(str_model = self.species) self.initializeVariables() def initializeVariables(self): """ Initialize widget """ self.lineEditValuePotElec.hide() self.lineEditValuePotElecIm.hide() self.lineEditValuePotVector.hide() self.labelValuePotVector.hide() self.labelValuePotElec.hide() self.labelValuePotElecIm.hide() self.pushButtonPotVectorFormula.setEnabled(False) setGreenColor(self.pushButtonPotVectorFormula, False) self.pushButtonPotElecFormula.setEnabled(False) setGreenColor(self.pushButtonPotElecFormula, False) self.pushButtonPotElecImFormula.setEnabled(False) setGreenColor(self.pushButtonPotElecImFormula, False) # Initialize electric potential self.potElec_type = self.__b.getElecScalarChoice(self.potElec) self.modelPotElec.setItem(str_model = self.potElec_type) if self.potElec_type == 'dirichlet' or self.potElec_type == 'neumann': self.lineEditValuePotElec.show() self.labelValuePotElec.show() v = self.__b.getElecScalarValue(self.potElec, self.potElec_type) self.lineEditValuePotElec.setText(str(v)) # Initialize imaginary electric potential if self.__model.getElectricalModel() == 'joule': if self.__model.getJouleModel() == 'three-phase' or \ self.__model.getJouleModel() == 'three-phase+Transformer': self.potElecIm_type = self.__b.getElecScalarChoice(self.potElecIm) self.modelPotElecIm.setItem(str_model = self.potElecIm_type) if self.potElecIm_type == 'dirichlet' or self.potElecIm_type == 'neumann': self.lineEditValuePotElecIm.show() self.labelValuePotElecIm.show() v = self.__b.getElecScalarValue(self.potElecIm, self.potElecIm_type) self.lineEditValuePotElecIm.setText(str(v)) # Initialize potential vector if self.__model.getElectricalModel() == 'arc': self.potVec_type = self.__b.getPotentialVectorChoice(self.potVect) self.modelPotVector.setItem(str_model = self.potVec_type) if self.potVec_type == 'dirichlet_formula': self.pushButtonPotVectorFormula.setEnabled(True) setGreenColor(self.pushButtonPotVectorFormula, True) # Initialize species if self.species : v = self.__b.getElecScalarValue(self.species, 'dirichlet') self.lineEditValueSpecies.setText(str(v)) @pyqtSignature("const QString&") def slotPotElecChoice(self, text): """ INPUT choice for electric potential type """ potElec_type = self.modelPotElec.dicoV2M[str(text)] self.__b.setElecScalarChoice(self.potElec, potElec_type) self.initializeVariables() @pyqtSignature("const QString&") def slotPotElecImChoice(self, text): """ INPUT choice for imaginary electric potential type """ potElecIm_type = self.modelPotElecIm.dicoV2M[str(text)] self.__b.setElecScalarChoice(self.potElecIm, potElecIm_type) self.initializeVariables() @pyqtSignature("const QString&") def slotPotVectorChoice(self, text): """ INPUT choice for potential vector type """ potVec_choice = self.modelPotVector.dicoV2M[str(text)] self.__b.setPotentialVectorChoice(self.potVect, potVec_choice) self.initializeVariables() @pyqtSignature("const QString&") def slotSpeciesChoice(self, text): """ INPUT species choice """ self.species = self.modelSpecies.dicoV2M[str(text)] self.initializeVariables() @pyqtSignature("const QString&") def slotPotVectorComponentChoice(self, text): """ INPUT potential vector component choice """ self.potVect = self.modelPotVectLabel.dicoV2M[str(text)] self.initializeVariables() @pyqtSignature("const QString&") def slotPotElec(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.potElec, self.potElec_type, value) @pyqtSignature("const QString&") def slotPotElecIm(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.potElecIm, self.potElecIm_type, value) @pyqtSignature("const QString&") def slotSpecies(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.species, 'dirichlet', value) @pyqtSignature("") def slotPotVectorFormula(self): """ """ exp = self.__b.getElecScalarFormula(self.potVect, self.potVec_type) exa = """#example: """ if not exp: exp = self.potVect + " = 0;" req = [(self.potVect, 'vector potential')] sym = [('x', "X cell's gravity center"), ('y', "Y cell's gravity center"), ('z', "Z cell's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] dialog = QMeiEditorView(self,expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotPotVectorFormula -> %s" % str(result)) self.__b.setElecScalarFormula(self.potVect, self.potVec_type, result) setGreenColor(self.pushButtonPotVectorFormula, False) def showWidget(self, b): """ Show the widget. """ self.__b = b if self.__model.getElectricalModel() != 'off': label = b.getLabel() nature = "joule_" + b.getNature() self.__b = Boundary(nature, label, self.__case) self.__setBoundary(b) self.show() else: self.hideWidget() def hideWidget(self): """ Hide all. """ self.hide() def tr(self, text): """ Translation. """ return text
class NeptuneWallTransferView(QWidget, Ui_NeptuneWallTransferForm): def __init__(self, parent, case): QWidget.__init__(self, parent) Ui_NeptuneWallTransferForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.xml_model = NeptuneWallTransferModel(self.case) self.set_connections() # Connections must be set before ComboModel is declared. self.combomodel_wallmodel = ComboModel(self.comboBoxWallTransferType) self.fill_widgets() self.initialize_widgets() self.update_view() def initialize_widgets(self): predefined_flow = MainFieldsModel(self.case).getPredefinedFlow() if predefined_flow in ["free_surface", "boiling_flow"]: self.combomodel_wallmodel.setItem(str_model="nucleate_boiling") self.setEnabled(False) elif predefined_flow == "droplet_flow": self.combomodel_wallmodel.setItem( str_model="droplet_evaporation_condensation") self.setEnabled(False) elif predefined_flow == "multiregime": self.combomodel_wallmodel.disableItem(str_model="none") self.combomodel_wallmodel.setItem( str_model=self.xml_model.wall_transfer_type) self.boilingWidget.setEnabled(False) self.dropletWidget.setEnabled(False) else: self.combomodel_wallmodel.setItem( str_model=self.xml_model.wall_transfer_type) def update_view(self): model = self.xml_model.wall_transfer_type self.boilingWidget.hide() self.dropletWidget.hide() if model == "nucleate_boiling": self.boilingWidget.setup(self.case) self.boilingWidget.show() elif model == "droplet_evaporation_condensation": self.dropletWidget.setup(self.case) self.dropletWidget.show() elif model == "none": pass else: raise ValueError("Unknown model {0}".format(model)) return def fill_widgets(self): self.combomodel_wallmodel.addItem(self.tr("None"), "none") self.combomodel_wallmodel.addItem(self.tr("Nucleate boiling"), "nucleate_boiling") self.combomodel_wallmodel.addItem( self.tr("Droplet evaporation/condensation"), "droplet_evaporation_condensation") return def set_connections(self): self.comboBoxWallTransferType.currentTextChanged[str].connect( self.slot_set_wall_model) @pyqtSlot(str) def slot_set_wall_model(self, text): model = self.combomodel_wallmodel.dicoV2M[text] self.xml_model.wall_transfer_type = model self.update_view() return
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
class ThermalScalarView(QWidget, Ui_ThermalScalarForm): """ Class to open Thermal Scalar Transport Page. """ def __init__(self, parent, case, tree): """ Constructor """ QWidget.__init__(self, parent) Ui_ThermalScalarForm.__init__(self) self.setupUi(self) self.browser = tree self.case = case self.case.undoStopGlobal() self.thermal = ThermalScalarModel(self.case) # combo Model self.modelThermal = ComboModel(self.comboBoxThermal, 4, 1) self.modelThermal.addItem(self.tr("No thermal scalar"), 'off') self.modelThermal.addItem(self.tr("Temperature (Celsius)"), 'temperature_celsius') self.modelThermal.addItem(self.tr("Temperature (Kelvin)"), 'temperature_kelvin') self.modelThermal.addItem(self.tr("Enthalpy (J/kg)"), 'enthalpy') self.modelThermal.addItem(self.tr("Potential temperature"), 'potential_temperature') self.modelThermal.addItem(self.tr("Liquid potential temperature"), 'liquid_potential_temperature') self.modelThermal.addItem(self.tr("Total energy (J/kg)"), 'total_energy') self.connect(self.comboBoxThermal, SIGNAL("activated(const QString&)"), self.slotThermalScalar) # Update the thermal scalar list with the calculation features for sca in self.thermal.thermalModel: if sca not in self.thermal.thermalScalarModelsList(): self.modelThermal.disableItem(str_model=sca) if ElectricalModel(self.case).getElectricalModel() != 'off': self.comboBoxThermal.setEnabled(False) if CoalCombustionModel(self.case).getCoalCombustionModel() != 'off': self.comboBoxThermal.setEnabled(False) if GasCombustionModel(self.case).getGasCombustionModel() != 'off': self.comboBoxThermal.setEnabled(False) if CompressibleModel(self.case).getCompressibleModel() != 'off': self.comboBoxThermal.setEnabled(False) else: self.modelThermal.delItem(6) if AtmosphericFlowsModel(self.case).getAtmosphericFlowsModel() != 'off': self.comboBoxThermal.setEnabled(False) else: self.modelThermal.delItem(5) self.modelThermal.delItem(4) # Select the thermal scalar model model = self.thermal.getThermalScalarModel() self.modelThermal.setItem(str_model=model) self.case.undoStartGlobal() @pyqtSignature("const QString &") def slotThermalScalar(self, text): """ Update the thermal scalar markup. """ th = self.modelThermal.dicoV2M[str(text)] self.thermal.setThermalModel(th) self.browser.configureTree(self.case) def tr(self, text): """ Translation """ return text
class PorosityView(QWidget, Ui_PorosityForm): def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_PorosityForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = PorosityModel(self.case) self.notebook = NotebookModel(self.case) # Create the Page layout. # Model and QTreeView for Head Losses self.modelPorosity = StandardItemModelPorosity() self.treeView.setModel(self.modelPorosity) # Combo model if self.case.module_name() == 'code_saturne': self.modelPorosityType = ComboModel(self.comboBoxType, 2, 1) self.modelPorosityType.addItem(self.tr("isotropic"), 'isotropic') self.modelPorosityType.addItem(self.tr("anisotropic"), 'anisotropic') else: self.modelPorosityType = ComboModel(self.comboBoxType, 1, 1) self.modelPorosityType.addItem(self.tr("isotropic"), 'isotropic') self.modelPorosityType.disableItem(index=0) # Connections self.treeView.clicked[QModelIndex].connect( self.slotSelectPorosityZones) self.comboBoxType.activated[str].connect(self.slotPorosity) self.pushButtonPorosity.clicked.connect(self.slotFormulaPorosity) # Initialize Widgets self.entriesNumber = -1 d = self.mdl.getNameAndLocalizationZone() liste = [] liste = list(d.items()) t = [] for t in liste: NamLoc = t[1] Lab = t[0] self.modelPorosity.insertItem(Lab, NamLoc[0], NamLoc[1]) self.forgetStandardWindows() self.case.undoStartGlobal() @pyqtSlot(QModelIndex) def slotSelectPorosityZones(self, index): label, name, local = self.modelPorosity.getItem(index.row()) if hasattr(self, "modelScalars"): del self.modelScalars log.debug("slotSelectPorosityZones label %s " % label) self.groupBoxType.show() self.groupBoxDef.show() choice = self.mdl.getPorosityModel(name) self.modelPorosityType.setItem(str_model=choice) exp = self.mdl.getPorosityFormula(name) if exp: self.pushButtonPorosity.setToolTip(exp) self.pushButtonPorosity.setStyleSheet("background-color: green") else: self.pushButtonPorosity.setStyleSheet("background-color: red") self.entriesNumber = index.row() def forgetStandardWindows(self): """ For forget standard windows """ self.groupBoxType.hide() self.groupBoxDef.hide() @pyqtSlot(str) def slotPorosity(self, text): """ Method to call 'getState' with correct arguements for 'rho' """ label, name, local = self.modelPorosity.getItem(self.entriesNumber) choice = self.modelPorosityType.dicoV2M[str(text)] self.mdl.setPorosityModel(name, choice) @pyqtSlot() def slotFormulaPorosity(self): """ User formula for density """ label, name, local = self.modelPorosity.getItem(self.entriesNumber) choice = self.mdl.getPorosityModel(name) fname = 'porosity' if choice == 'anisotropic': fname += '+tensorial_porosity' exp, req, sca, sym = self.mdl.getPorosityFormulaComponents(name) if exp == None: exp = self.getDefaultPorosityFormula(choice) exa = """#example: \n""" + self.mdl.getDefaultPorosityFormula(choice) dialog = QMegEditorView(parent=self, function_type='vol', zone_name=label, variable_name=fname, expression=exp, required=req, symbols=sym, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaPorosity -> %s" % str(result)) self.mdl.setPorosityFormula(name, str(result)) self.pushButtonPorosity.setToolTip(result) self.pushButtonPorosity.setStyleSheet("background-color: green")
class TimeStepView(QWidget, Ui_TimeStepForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_TimeStepForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = TimeStepModel(self.case) # Combo model self.modelTimeOptions = ComboModel(self.comboBoxOptions, 2, 1) self.modelTimeOptions.addItem(self.tr("Constant"), '0') self.modelTimeOptions.addItem(self.tr("Variable"), '1') # Connections self.comboBoxOptions.activated[str].connect(self.slotTimePassing) self.lineEditDTREF.textChanged[str].connect(self.slotTimeStep) self.lineEditNTMABS.textChanged[str].connect(self.slotIter) self.lineEditCOUMAX.textChanged[str].connect(self.slotTimeOptionCOUMAX) self.lineEditFOUMAX.textChanged[str].connect(self.slotTimeOptionFOUMAX) self.lineEditCDTMIN.textChanged[str].connect(self.slotTimeOptionCDTMIN) self.lineEditCDTMAX.textChanged[str].connect(self.slotTimeOptionCDTMAX) self.lineEditVARRDT.textChanged[str].connect(self.slotTimeOptionVARRDT) self.checkBoxIPTLRO.clicked.connect(self.slotThermalTimeStep) self.checkBoxINPDT0.clicked.connect(self.slotZeroTimeStep) # Validators validatorDTREF = DoubleValidator(self.lineEditDTREF, min=0.0) validatorDTREF.setExclusiveMin(True) validatorNTMABS = IntValidator(self.lineEditNTMABS, min=1) validatorCOUMAX = DoubleValidator(self.lineEditCOUMAX, min=0.0) validatorCOUMAX.setExclusiveMin(True) validatorFOUMAX = DoubleValidator(self.lineEditFOUMAX, min=0.0) validatorFOUMAX.setExclusiveMin(True) validatorCDTMIN = DoubleValidator(self.lineEditCDTMIN, min=0.0, max=1.0) validatorCDTMIN.setExclusiveMin(True) validatorCDTMAX = DoubleValidator(self.lineEditCDTMAX, min=1.0) validatorVARRDT = DoubleValidator(self.lineEditVARRDT, min=0.0, max=1.0) validatorVARRDT.setExclusiveMin(True) self.lineEditDTREF.setValidator(validatorDTREF) self.lineEditNTMABS.setValidator(validatorNTMABS) self.lineEditCOUMAX.setValidator(validatorCOUMAX) self.lineEditFOUMAX.setValidator(validatorFOUMAX) self.lineEditCDTMIN.setValidator(validatorCDTMIN) self.lineEditCDTMAX.setValidator(validatorCDTMAX) self.lineEditVARRDT.setValidator(validatorVARRDT) # Initialization status = SteadyManagementModel(self.case).getSteadyFlowManagement() if status == 'on': self.comboBoxOptions.hide() self.mdl.setTimePassing(2) courant_max = self.mdl.getOptions('max_courant_num') fourier_max = self.mdl.getOptions('max_fourier_num') time_step_min_factor = self.mdl.getOptions('time_step_min_factor') time_step_max_factor = self.mdl.getOptions('time_step_max_factor') time_step_var = self.mdl.getOptions('time_step_var') self.lineEditCOUMAX.setText(str(courant_max)) self.lineEditFOUMAX.setText(str(fourier_max)) self.lineEditCDTMIN.setText(str(time_step_min_factor)) self.lineEditCDTMAX.setText(str(time_step_max_factor)) self.lineEditVARRDT.setText(str(time_step_var)) self.groupBoxLabels.show() else: self.comboBoxOptions.show() idtvar = self.mdl.getTimePassing() self.modelTimeOptions.setItem(str_model=str(idtvar)) from code_saturne.Pages.TurbulenceModel import TurbulenceModel model = TurbulenceModel(self.case).getTurbulenceModel() del TurbulenceModel if model in ('LES_Smagorinsky', 'LES_dynamique', 'LES_WALE'): idtvar = 0 self.modelTimeOptions.setItem(str_model=str(idtvar)) self.modelTimeOptions.disableItem(str_model='0') self.modelTimeOptions.disableItem(str_model='1') text = self.comboBoxOptions.currentText() self.slotTimePassing(text) dtref = self.mdl.getTimeStep() self.lineEditDTREF.setText(str(dtref)) ntmabs = self.mdl.getIterationsNumber() self.lineEditNTMABS.setText(str(ntmabs)) if self.mdl.thermalCase(): if self.mdl.getThermalTimeStep() == 'on': self.checkBoxIPTLRO.setChecked(True) else: self.checkBoxIPTLRO.setChecked(False) else: self.lineIPTLRO.hide() self.labelIPTLRO.hide() self.checkBoxIPTLRO.hide() self.mdl.RemoveThermalTimeStepNode() if self.mdl.getZeroTimeStep() == 'on': self.checkBoxINPDT0.setChecked(True) else: self.checkBoxINPDT0.setChecked(False) self.case.undoStartGlobal() @pyqtSlot(str) def slotTimePassing(self, text): """ Input IDTVAR. """ idtvar = int(self.modelTimeOptions.dicoV2M[str(text)]) self.mdl.setTimePassing(idtvar) if idtvar in (1, 2): courant_max = self.mdl.getOptions('max_courant_num') fourier_max = self.mdl.getOptions('max_fourier_num') time_step_min_factor = self.mdl.getOptions('time_step_min_factor') time_step_max_factor = self.mdl.getOptions('time_step_max_factor') time_step_var = self.mdl.getOptions('time_step_var') self.lineEditCOUMAX.setText(str(courant_max)) self.lineEditFOUMAX.setText(str(fourier_max)) self.lineEditCDTMIN.setText(str(time_step_min_factor)) self.lineEditCDTMAX.setText(str(time_step_max_factor)) self.lineEditVARRDT.setText(str(time_step_var)) self.groupBoxLabels.show() else: self.groupBoxLabels.hide() @pyqtSlot(str) def slotTimeStep(self, text): """ Input DTREF. """ if self.lineEditDTREF.validator().state == QValidator.Acceptable: time_step = from_qvariant(text, float) self.mdl.setTimeStep(time_step) @pyqtSlot(str) def slotIter(self, text): """ Input NTMABS. """ if self.lineEditNTMABS.validator().state == QValidator.Acceptable: iteration = from_qvariant(text, int) self.mdl.setIterationsNumber(iteration) @pyqtSlot(str) def slotTimeOptionCOUMAX(self, text): """ Input COUMAX. """ if self.lineEditCOUMAX.validator().state == QValidator.Acceptable: courant_max = from_qvariant(text, float) self.mdl.setOptions('max_courant_num', courant_max) @pyqtSlot(str) def slotTimeOptionFOUMAX(self, text): """ Input FOUMAX. """ if self.lineEditFOUMAX.validator().state == QValidator.Acceptable: fourier_max = from_qvariant(text, float) self.mdl.setOptions('max_fourier_num', fourier_max) @pyqtSlot(str) def slotTimeOptionCDTMIN(self, text): """ Input CDTMIN. """ if self.lineEditCDTMIN.validator().state == QValidator.Acceptable: time_step_min_factor = from_qvariant(text, float) self.mdl.setOptions('time_step_min_factor', time_step_min_factor) @pyqtSlot(str) def slotTimeOptionCDTMAX(self, text): """ Input CDTMAX. """ if self.lineEditCDTMAX.validator().state == QValidator.Acceptable: time_step_max_factor = from_qvariant(text, float) self.mdl.setOptions('time_step_max_factor', time_step_max_factor) @pyqtSlot(str) def slotTimeOptionVARRDT(self, text): """ Input VARRDT. """ if self.lineEditVARRDT.validator().state == QValidator.Acceptable: time_step_var = from_qvariant(text, float) self.mdl.setOptions('time_step_var', time_step_var) @pyqtSlot() def slotThermalTimeStep(self): """ Input IPTLRO. """ if self.checkBoxIPTLRO.isChecked(): self.mdl.setThermalTimeStep("on") else: self.mdl.setThermalTimeStep("off") @pyqtSlot() def slotZeroTimeStep(self): """ Input INPDT0. """ if self.checkBoxINPDT0.isChecked(): self.mdl.setZeroTimeStep("on") else: self.mdl.setZeroTimeStep("off") def tr(self, text): """ Translation """ return text
class OpenTurnsView(QWidget, Ui_OpenTurnsForm): """ OpenTurns Page viewer class """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_OpenTurnsForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = OpenTurnsModel(case) if not self.mdl.getHostName(): self.mdl.setDefaultOptions() # Combo model config = configparser.ConfigParser() config.read(self.case['package'].get_configfiles()) self.nmodes = 1 dist_hosts = None if config.has_section('distant_hosts'): if len(config.options('distant_hosts')) != 0: dist_hosts = config.options('distant_hosts') self.nmodes += len(dist_hosts) self.modelOtStudyHosts = ComboModel(self.comboBoxStudyMode, self.nmodes, 1) self.modelOtStudyHosts.addItem(self.tr("Localhost"), 'localhost') self.hosts_bmgr = {} if config.has_option('install', 'batch'): self.hosts_bmgr['localhost'] = (config.get('install', 'batch')).lower() else: self.hosts_bmgr['localhost'] = 'none' # Check for distant builds: # Hosts are stored in the form <batch_rm>_<host_name> hence the split # used hereafter to determine the "real" host name self.hosts_binpath = {} self.hosts_binpath['localhost'] = 'default' self.distant_host_builds = None if dist_hosts != None: self.distant_host_builds = {} for key in dist_hosts: host_name = key.split('_')[1] self.hosts_bmgr[host_name] = key.split('_')[0] self.hosts_binpath[host_name] = config.get( 'distant_hosts', key) self.addDistantBuilds(host_name) dh_not_found = False if self.distant_host_builds[host_name] == None: self.distant_host_builds[host_name] = ['none found'] dh_not_found = True host_tag = 'distant : ' + host_name self.modelOtStudyHosts.addItem(self.tr(host_tag), host_name, warn=dh_not_found) if dh_not_found: self.modelOtStudyHosts.disableItem(str_model=host_name) # --------------------------------------- # Connections: self.comboBoxStudyMode.activated[str].connect(self.slotOtStudyMode) self.comboBoxDistantBuilds.activated[str].connect(self.slotBuildChoice) self.lineEditDistWorkDir.textChanged[str].connect(self.slotOtDistWdir) self.spinBoxNumberNodes.valueChanged[int].connect( self.slotUpdateNodesNumber) self.spinBoxNumberTasks.valueChanged[int].connect( self.slotUpdateTasksNumber) self.spinBoxNumberThreads.valueChanged[int].connect( self.slotUpdateThreadsNumber) self.spinBoxNumberDays.valueChanged[int].connect(self.slotUpdateWCDays) self.spinBoxNumberHours.valueChanged[int].connect( self.slotUpdateWCHours) self.spinBoxNumberMinutes.valueChanged[int].connect( self.slotUpdateWCMinutes) self.spinBoxNumberSeconds.valueChanged[int].connect( self.slotUpdateWCSeconds) self.lineEditWCKEY.textChanged[str].connect(self.slotUpdateWckey) self.lineEditOutputFile.textChanged[str].connect( self.slotUpdateResultsFile) self.pushButtonLaunchOT.clicked.connect(self.slotLaunchCsOt) # --------------------------------------- # Hide/Show initial elements if self.nmodes == 1: self.groupBoxLocalLaunch.show() self.groupBoxDistantLaunch.hide() self.setAvailableBuildsList('localhost') else: self.setAvailableBuildsList(self.mdl.getHostName()) if self.mdl.getHostName() == "localhost": self.groupBoxLocalLaunch.show() self.groupBoxDistantLaunch.hide() else: self.groupBoxLocalLaunch.hide() self.groupBoxDistantLaunch.show() # --------------------------------------- # Initial values self.lineEditOutputFile.setText(self.mdl.resfile_name) if dist_hosts != None: self.modelOtStudyHosts.setItem(str_model=self.mdl.host_name) else: self.modelOtStudyHosts.setItem(str_model='localhost') self.spinBoxLocalProcs.setValue(int(self.mdl.nprocs)) self.spinBoxLocalThreads.setValue(1) self.spinBoxNumberNodes.setValue(int(self.mdl.nnodes)) self.spinBoxNumberTasks.setValue(int(self.mdl.ntasks)) self.spinBoxNumberThreads.setValue(int(self.mdl.nthreads)) wct = self.mdl.getWallClockTime() self.spinBoxNumberDays.setValue(int(wct[0])) self.spinBoxNumberHours.setValue(int(wct[1])) self.spinBoxNumberMinutes.setValue(int(wct[2])) self.spinBoxNumberSeconds.setValue(int(wct[3])) self.lineEditWCKEY.setText(self.mdl.getWCKEY()) self.lineEditOutputFile.setText(self.mdl.getResultsFile()) @pyqtSlot(str) def slotOtStudyMode(self, text): """ Host type: localhost or a distant one (defined in code_saturne.cfg). """ host_name = self.modelOtStudyHosts.dicoV2M[str(text)] self.mdl.setHostName(host_name) self.mdl.setBatchManager(self.hosts_bmgr[host_name]) if host_name != 'localhost': self.groupBoxDistantLaunch.show() else: self.groupBoxDistantLaunch.hide() self.setAvailableBuildsList(host_name) self.mdl.arch_path = self.hosts_binpath[host_name] @pyqtSlot(str) def slotBuildChoice(self, text): """ Sets the hostname """ self.mdl.setBuildName(text) @pyqtSlot(str) def slotOtDistWdir(self, text): """ Set the distant workdir path """ self.mdl.setDistWorkdir(text) @pyqtSlot(int) def slotUpdateNodesNumber(self, v): """ Update the number of required computation nodes """ n = int(self.spinBoxNumberNodes.text()) self.mdl.setClusterParams(nnodes=n) @pyqtSlot(int) def slotUpdateNprocs(self, v): """ Update the number of required processes """ n = int(self.spinBoxLocalProcs.text()) self.mdl.setNprocs(n) @pyqtSlot(int) def slotUpdateTasksNumber(self, v): """ Update the number of required mpi tasks per node """ n = int(self.spinBoxNumberTasks.text()) self.mdl.setClusterParams(ntasks=n) @pyqtSlot(int) def slotUpdateThreadsNumber(self, v): """ Update the number of required threads per processor """ n = int(self.spinBoxNumberThreads.text()) self.mdl.setClusterParams(nthreads=n) @pyqtSlot(int) def slotUpdateWCDays(self, v): """ Update the wall clock days value """ d, h, m, s = self.mdl.getWallClockTime() d = str(int(self.spinBoxNumberDays.text())) self.mdl.setWallClockTime(d, h, m, s) @pyqtSlot(int) def slotUpdateWCHours(self, v): """ Update the wall clock hours value """ d, h, m, s = self.mdl.getWallClockTime() h = str(int(self.spinBoxNumberHours.text())) self.mdl.setWallClockTime(d, h, m, s) @pyqtSlot(int) def slotUpdateWCMinutes(self, v): """ Update the wall clock minutes value """ d, h, m, s = self.mdl.getWallClockTime() m = str(int(self.spinBoxNumberMinutes.text())) self.mdl.setWallClockTime(d, h, m, s) @pyqtSlot(int) def slotUpdateWCSeconds(self, v): """ Update the wall clock seconds value """ d, h, m, s = self.mdl.getWallClockTime() s = str(int(self.spinBoxNumberSeconds.text())) self.mdl.setWallClockTime(d, h, m, s) @pyqtSlot(str) def slotUpdateWckey(self, text): """ Update the WCKEY variable """ self.mdl.setWCKEY(text) @pyqtSlot(str) def slotUpdateResultsFile(self, text): """ Update the outputfile name """ self.mdl.setResultsFile(text) @pyqtSlot() def slotLaunchCsOt(self): """ Translate the Code_Sature reference case and study into an OpenTurs physical model and study """ if self.case['salome']: import salome_ot # Update the study cfg file self.mdl.update_cfg_file() # Generating OpenTurns _exec function self.create_cs_exec_function() # Load the Code_Saturne cas as Physical model and launch # OpenTurns GUI cs_exec_script_name = os.path.join(self.mdl.otstudy_path, 'cs_execute_job.py') salome_ot.loadYacsPyStudy(cs_exec_script_name) else: print( "This option is only available within the SALOME_CFD platform") def tr(self, text): """ Translation """ return text def addDistantBuilds(self, host_name): """ Search for the distant builds of Code_Saturne for the given distant host. """ host_path = self.hosts_binpath[host_name] builds_list = __getListOfDistantBuilds__(host_name, host_path) self.distant_host_builds[host_name] = builds_list def setAvailableBuildsList(self, host_name): """ Set the list of available builds per host """ if host_name == 'localhost': self.groupBoxDistantLaunch.hide() self.groupBoxLocalLaunch.show() self.comboBoxDistantBuilds.hide() self.labelDistantBuilds.hide() return else: self.groupBoxDistantLaunch.show() self.groupBoxLocalLaunch.hide() self.comboBoxDistantBuilds.show() self.labelDistantBuilds.show() dist_builds_list = self.distant_host_builds[host_name] self.modelOtDistantBuilds = ComboModel(self.comboBoxDistantBuilds, len(dist_builds_list), 1) for db in dist_builds_list: self.modelOtDistantBuilds.addItem(self.tr(db), db) def create_cs_exec_function(self): """ This function generates the _exec function needed by OpenTurns for a study using distant launching on clusters. Takes as input: - Code_Saturne study path - OT_params.cfg name - list of OTurns input variables - list of OTurns output variables - the requested cluster name - the result file name which contains the output values """ cluster = self.mdl.host_name exec_file_name = os.path.join(self.mdl.otstudy_path, 'cs_execute_job.py') f = open(exec_file_name, 'w') script_cmd = "\n" script_cmd += "# ============================================================================== \n" script_cmd += "# OPENTURNS EXEC FUNCTION WHICH LAUNCHES CODE_SATURNE ON A DISTANT CLUSTER \n" script_cmd += "# ============================================================================== \n" script_cmd += "\n\n" nvars = len(self.mdl.input_variables) script_cmd = 'def _exec(' vars_dict = '{' toffset = ' ' cmd1 = 'cfd_eval = cfd_openturns_study(' loffset1 = toffset for i in range(len(cmd1)): loffset1 += ' ' loffset2 = ' ' iv = -1 for i in range(nvars): if i == 0: script_cmd += self.mdl.input_variables[i] vars_dict += '"' + self.mdl.input_variables[i] + '":' vars_dict += self.mdl.input_variables[i] else: script_cmd += ", " + self.mdl.input_variables[i] vars_dict += ', \n' vars_dict += loffset1 + loffset2 + ' ' vars_dict += '"' + self.mdl.input_variables[i] + '":' vars_dict += self.mdl.input_variables[i] script_cmd += '):\n\n' vars_dict += '}' script_cmd += toffset + "import sys\n" salome_pydir = os.path.join(self.case['package'].dirs['pythondir'][1], 'salome') script_cmd += toffset script_cmd += "sys.path.insert(-1, '%s')\n\n" % salome_pydir script_cmd += toffset + "from CFDSTUDYOTURNS_StudyInterface import cfd_openturns_study" script_cmd += "\n\n" script_cmd += toffset + cmd1 + 'study_path = "' + self.mdl.otstudy_path + '",\n' script_cmd += loffset1 + 'study_cfg = "openturns_study.cfg",\n' script_cmd += loffset1 + 'vars_dico = ' + vars_dict + ')\n\n' script_cmd += toffset + 'cfd_eval.study2code() \n\n' script_cmd += toffset + 'cfd_eval.run() \n\n' n_vals = len(self.mdl.output_variables) vals_list = "" for i in range(n_vals): if i != 0: vals_list += ', ' vals_list += self.mdl.output_variables[i] cmd_m1 = '(%s,) = cfd_eval.code2study(n_values=%d)\n' % (vals_list, n_vals) script_cmd += toffset + cmd_m1 script_cmd += '\n' script_cmd += toffset + 'return ' script_cmd += vals_list + '\n' f.write(script_cmd) f.close()
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 PorosityView(QWidget, Ui_PorosityForm): def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_PorosityForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = PorosityModel(self.case) self.notebook = NotebookModel(self.case) # Create the Page layout. # Model and QTreeView for Head Losses self.modelPorosity = StandardItemModelPorosity() self.treeView.setModel(self.modelPorosity) # Combo model if self.case['package'].name == 'code_saturne': self.modelPorosityType = ComboModel(self.comboBoxType, 2, 1) self.modelPorosityType.addItem(self.tr("isotropic"), 'isotropic') self.modelPorosityType.addItem(self.tr("anisotropic"), 'anisotropic') else: self.modelPorosityType = ComboModel(self.comboBoxType, 1, 1) self.modelPorosityType.addItem(self.tr("isotropic"), 'isotropic') self.modelPorosityType.disableItem(index=0) # Connections self.treeView.clicked[QModelIndex].connect(self.slotSelectPorosityZones) self.comboBoxType.activated[str].connect(self.slotPorosity) self.pushButtonPorosity.clicked.connect(self.slotFormulaPorosity) # Initialize Widgets self.entriesNumber = -1 d = self.mdl.getNameAndLocalizationZone() liste=[] liste=list(d.items()) t=[] for t in liste : NamLoc=t[1] Lab=t[0 ] self.modelPorosity.insertItem(Lab, NamLoc[0],NamLoc[1]) self.forgetStandardWindows() self.case.undoStartGlobal() @pyqtSlot(QModelIndex) def slotSelectPorosityZones(self, index): label, name, local = self.modelPorosity.getItem(index.row()) if hasattr(self, "modelScalars"): del self.modelScalars log.debug("slotSelectPorosityZones label %s " % label ) self.groupBoxType.show() self.groupBoxDef.show() choice = self.mdl.getPorosityModel(name) self.modelPorosityType.setItem(str_model=choice) exp = self.mdl.getPorosityFormula(name) if exp: self.pushButtonPorosity.setToolTip(exp) self.pushButtonPorosity.setStyleSheet("background-color: green") else: self.pushButtonPorosity.setStyleSheet("background-color: red") self.entriesNumber = index.row() def forgetStandardWindows(self): """ For forget standard windows """ self.groupBoxType.hide() self.groupBoxDef.hide() @pyqtSlot(str) def slotPorosity(self, text): """ Method to call 'getState' with correct arguements for 'rho' """ label, name, local = self.modelPorosity.getItem(self.entriesNumber) choice = self.modelPorosityType.dicoV2M[str(text)] self.mdl.setPorosityModel(name, choice) @pyqtSlot() def slotFormulaPorosity(self): """ User formula for density """ label, name, local = self.modelPorosity.getItem(self.entriesNumber) exp = self.mdl.getPorosityFormula(name) choice = self.mdl.getPorosityModel(name) if exp == None: exp = self.getDefaultPorosityFormula(choice) if choice == "isotropic": req = [('porosity', 'Porosity')] else: req = [('porosity', 'Porosity'), ('porosity[XX]', 'Porosity'), ('porosity[YY]', 'Porosity'), ('porosity[ZZ]', 'Porosity'), ('porosity[XY]', 'Porosity'), ('porosity[XZ]', 'Porosity'), ('porosity[YZ]', 'Porosity')] exa = """#example: \n""" + self.mdl.getDefaultPorosityFormula(choice) sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaPorosity -> %s" % str(result)) self.mdl.setPorosityFormula(name, str(result)) self.pushButtonPorosity.setToolTip(result) self.pushButtonPorosity.setStyleSheet("background-color: green") def tr(self, text): """ Translation """ return text
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 ElectricalView(QWidget, Ui_ElectricalForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_ElectricalForm.__init__(self) self.setupUi(self) self.case = case self.stbar = stbar self.case.undoStopGlobal() self.model = ElectricalModel(self.case) # Combo model self.modelJoule = ComboModel(self.comboBoxJouleModel, 4, 1) self.modelJoule.addItem(self.tr("AC/DC"), "AC/DC") self.modelJoule.addItem(self.tr("three-phase"), "three-phase") self.modelJoule.addItem(self.tr("AC/DC with Transformer coupling"), "AC/DC+Transformer") self.modelJoule.addItem(self.tr("three-phase with Transformer coupling"), "three-phase+Transformer") self.modelJoule.disableItem(str_model="AC/DC+Transformer") self.modelJoule.disableItem(str_model="three-phase+Transformer") self.modelScaling = ComboModel(self.comboBoxScalingModel, 3, 1) self.modelScaling.addItem(self.tr("general case"), "general_case") self.modelScaling.addItem(self.tr("plane define"), "plane_define") self.modelScaling.addItem(self.tr("user define"), "user") self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("X"), "X") self.modelDirection.addItem(self.tr("Y"), "Y") self.modelDirection.addItem(self.tr("Z"), "Z") # Connections self.connect(self.pushButtonPropertiesData, SIGNAL("pressed()"), self.__slotSearchPropertiesData) self.connect(self.lineEditSRROM, SIGNAL("textChanged(const QString &)"), self.slotSRROM) self.connect(self.lineEditPower, SIGNAL("textChanged(const QString &)"), self.slotPower) self.connect(self.lineEditCurrent, SIGNAL("textChanged(const QString &)"), self.slotCurrent) self.connect(self.checkBoxScaling, SIGNAL("clicked()"), self.slotScaling) self.connect(self.comboBoxJouleModel, SIGNAL("activated(const QString&)"), self.slotJouleModel) self.connect(self.comboBoxScalingModel, SIGNAL("activated(const QString&)"), self.slotScalingModel) self.connect(self.comboBoxDirection, SIGNAL("clicked()"), self.slotDirection) self.connect(self.lineEditPlaneDefinitionA, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefA) self.connect(self.lineEditPlaneDefinitionB, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefB) self.connect(self.lineEditPlaneDefinitionC, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefC) self.connect(self.lineEditPlaneDefinitionD, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefD) self.connect(self.lineEditEpsilon, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefEpsilon) # Validators validatorSRROM = DoubleValidator(self.lineEditSRROM, min=0.0, max=1.0) validatorSRROM.setExclusiveMin(False) validatorPower = DoubleValidator(self.lineEditPower, min=0.0) validatorPower.setExclusiveMin(False) validatorCurrent = DoubleValidator(self.lineEditCurrent, min=0.0) validatorCurrent.setExclusiveMin(False) validatorDefinitionA = DoubleValidator(self.lineEditPlaneDefinitionA) validatorDefinitionB = DoubleValidator(self.lineEditPlaneDefinitionB) validatorDefinitionC = DoubleValidator(self.lineEditPlaneDefinitionC) validatorDefinitionD = DoubleValidator(self.lineEditPlaneDefinitionD) validatorEpsilon = DoubleValidator(self.lineEditEpsilon) self.lineEditSRROM.setValidator(validatorSRROM) self.lineEditPower.setValidator(validatorPower) self.lineEditCurrent.setValidator(validatorCurrent) self.lineEditPlaneDefinitionA.setValidator(validatorDefinitionA) self.lineEditPlaneDefinitionB.setValidator(validatorDefinitionB) self.lineEditPlaneDefinitionC.setValidator(validatorDefinitionC) self.lineEditPlaneDefinitionD.setValidator(validatorDefinitionD) self.lineEditEpsilon.setValidator(validatorEpsilon) # Initialize widget self.__initializeWidget() self.case.undoStartGlobal() @pyqtSignature("") def __initializeWidget(self): """ Initialize widget """ name = self.model.getPropertiesDataFileName() if name != None: self.labelPropertiesFile.setText(str(name)) setGreenColor(self.pushButtonPropertiesData, False) else: setGreenColor(self.pushButtonPropertiesData, True) srrom = self.model.getSRROM() self.lineEditSRROM.setText(str(srrom)) self.groupBoxRecalage.hide() if self.model.getScaling() == 'on': self.checkBoxScaling.setChecked(True) self.labelScalingModel.show() self.comboBoxScalingModel.show() else: self.checkBoxScaling.setChecked(False) self.labelScalingModel.hide() self.comboBoxScalingModel.hide() if self.model.getElectricalModel() == "joule": self.groupBoxJoule.show() self.groupBoxElectricArc.hide() model = self.model.getJouleModel() self.modelJoule.setItem(str_model=str(model)) power = self.model.getPower() self.lineEditPower.setText(str(power)) self.labelPropertiesData.hide() self.pushButtonPropertiesData.hide() self.labelPropertiesFile.hide() self.pushButtonPropertiesData.hide() self.labelPropertiesData.hide() self.labelPropertiesFile.hide() elif self.model.getElectricalModel() == "arc": self.groupBoxJoule.hide() self.groupBoxElectricArc.show() current = self.model.getCurrent() self.lineEditCurrent.setText(str(current)) if self.model.getScaling() == 'on': model = self.model.getScalingModel() self.modelScaling.setItem(str_model=str(model)) if model == 'plane_define': self.groupBoxRecalage.show() direction = self.model.getDirection() self.modelDirection.setItem(str_model=str(direction)) definition = self.model.getPlaneDefinition("A") self.lineEditPlaneDefinitionA.setText(str(definition)) definition = self.model.getPlaneDefinition("B") self.lineEditPlaneDefinitionB.setText(str(definition)) definition = self.model.getPlaneDefinition("C") self.lineEditPlaneDefinitionC.setText(str(definition)) definition = self.model.getPlaneDefinition("D") self.lineEditPlaneDefinitionD.setText(str(definition)) definition = self.model.getPlaneDefinition("epsilon") self.lineEditEpsilon.setText(str(definition)) @pyqtSignature("") def __slotSearchPropertiesData(self): """ Select a properties file of data for electric arc """ data = self.case['data_path'] title = self.tr("Properties file of data.") filetypes = self.tr("Properties data (*dp_ELE*);;All Files (*)") file = QFileDialog.getOpenFileName(self, title, data, filetypes) file = str(file) if not file: return file = os.path.basename(file) if file not in os.listdir(data): title = self.tr("WARNING") msg = self.tr("This selected file is not in the DATA directory") QMessageBox.information(self, title, msg) else: self.labelPropertiesFile.setText(str(file)) self.model.setPropertiesDataFileName(file) setGreenColor(self.pushButtonPropertiesData, False) @pyqtSignature("const QString &") def slotSRROM(self, text): """ Input Relaxation coefficient for mass density """ if self.sender().validator().state == QValidator.Acceptable: srrom = from_qvariant(text, float) self.model.setSRROM(srrom) @pyqtSignature("const QString &") def slotPower(self, text): """ Input Imposed Power """ if self.sender().validator().state == QValidator.Acceptable: power = from_qvariant(text, float) self.model.setPower(power) @pyqtSignature("const QString &") def slotCurrent(self, text): """ Input Imposed current intensity """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setCurrent(current) @pyqtSignature("") def slotJouleModel(self, text): """ Input Joule model. """ model = self.modelJoule.dicoV2M[str(text)] self.model.setJouleModel(model) @pyqtSignature("") def slotScaling(self): """ Input "Electric variables" scaling. """ if self.checkBoxScaling.isChecked(): self.model.setScaling("on") else: self.model.setScaling("off") self.__initializeWidget() @pyqtSignature("") def slotScalingModel(self, text): """ Input scaling model. """ model = self.modelScaling.dicoV2M[str(text)] self.model.setScalingModel(model) self.__initializeWidget() @pyqtSignature("") def slotDirection(self, text): """ Input current density direction for scaling. """ direction = self.modelDirection.dicoV2M[str(text)] self.model.setDirection(direction) @pyqtSignature("const QString &") def slotPlaneDefA(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("A", current) @pyqtSignature("const QString &") def slotPlaneDefB(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("B", current) @pyqtSignature("const QString &") def slotPlaneDefC(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("C", current) @pyqtSignature("const QString &") def slotPlaneDefD(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("D", current) @pyqtSignature("const QString &") def slotPlaneDefEpsilon(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("epsilon", current) def tr(self, text): """ Translation. """ return text
class TurbulenceView(QWidget, Ui_TurbulenceForm): """ Class to open Turbulence Page. """ def __init__(self, parent=None, case=None): """ Constructor """ QWidget.__init__(self, parent) Ui_TurbulenceForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = TurbulenceModel(self.case) # Combo model self.modelTurbModel = ComboModel(self.comboBoxTurbModel,10,1) self.modelTurbModel.addItem(self.tr("No model (i.e. laminar flow)"), "off") self.modelTurbModel.addItem(self.tr("Mixing length"), "mixing_length") self.modelTurbModel.addItem(self.tr("k-epsilon"), "k-epsilon") self.modelTurbModel.addItem(self.tr("k-epsilon Linear Production"), "k-epsilon-PL") self.modelTurbModel.addItem(self.tr("Rij-epsilon LRR"), "Rij-epsilon") self.modelTurbModel.addItem(self.tr("Rij-epsilon SSG"), "Rij-SSG") self.modelTurbModel.addItem(self.tr("Rij-epsilon EBRSM"), "Rij-EBRSM") self.modelTurbModel.addItem(self.tr("v2f BL-v2/k"), "v2f-BL-v2/k") self.modelTurbModel.addItem(self.tr("k-omega SST"), "k-omega-SST") self.modelTurbModel.addItem(self.tr("Spalart-Allmaras"), "Spalart-Allmaras") self.modelTurbModel.addItem(self.tr("LES (Smagorinsky)"), "LES_Smagorinsky") self.modelTurbModel.addItem(self.tr("LES (classical dynamic model)"), "LES_dynamique") self.modelTurbModel.addItem(self.tr("LES (WALE)"), "LES_WALE") # Connections self.connect(self.comboBoxTurbModel, SIGNAL("activated(const QString&)"), self.slotTurbulenceModel) self.connect(self.pushButtonAdvanced, SIGNAL("clicked()"), self.slotAdvancedOptions) self.connect(self.lineEditLength, SIGNAL("textChanged(const QString &)"), self.slotLengthScale) # Frames display self.frameAdvanced.hide() self.frameLength.hide() # Validator validator = DoubleValidator(self.lineEditLength, min=0.0) validator.setExclusiveMin(True) self.lineEditLength.setValidator(validator) # Update the turbulence models list with the calculation features for turb in self.model.turbulenceModels(): if turb not in self.model.turbulenceModelsList(): self.modelTurbModel.disableItem(str_model=turb) # Select the turbulence model model = self.model.getTurbulenceModel() self.modelTurbModel.setItem(str_model=model) self.slotTurbulenceModel(self.comboBoxTurbModel.currentText()) # Length scale l_scale = self.model.getLengthScale() self.lineEditLength.setText(str(l_scale)) self.case.undoStartGlobal() @pyqtSignature("const QString&") def slotLengthScale(self, text): """ Private slot. Input XLOMLG. """ if self.sender().validator().state == QValidator.Acceptable: l_scale = from_qvariant(text, float) self.model.setLengthScale(l_scale) @pyqtSignature("const QString&") def slotTurbulenceModel(self, text): """ Private slot. Input ITURB. """ model = self.modelTurbModel.dicoV2M[str(text)] self.model.setTurbulenceModel(model) self.frameAdvanced.hide() self.frameLength.hide() if model == 'mixing_length': self.frameLength.show() self.frameAdvanced.hide() self.model.getLengthScale() elif model not in ('off', 'LES_Smagorinsky', 'LES_dynamique', 'LES_WALE', 'Spalart-Allmaras'): self.frameLength.hide() self.frameAdvanced.show() if model in ('off', 'LES_Smagorinsky', 'LES_dynamique', 'LES_WALE', 'Spalart-Allmaras'): self.line.hide() else: self.line.show() @pyqtSignature("") def slotAdvancedOptions(self): """ Private slot. Ask one popup for advanced specifications """ default = {} default['model'] = self.model.getTurbulenceModel() default['scale_model'] = self.model.getScaleModel() default['gravity_terms'] = self.model.getGravity() log.debug("slotAdvancedOptions -> %s" % str(default)) dialog = TurbulenceAdvancedOptionsDialogView(self, self.case, default) if dialog.exec_(): result = dialog.get_result() log.debug("slotAdvancedOptions -> %s" % str(result)) self.model.setTurbulenceModel(result['model']) self.model.setScaleModel(result['scale_model']) self.model.setGravity(result['gravity_terms']) def tr(self, text): """ Translation """ return text