class MeshDimDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, mdl): super(MeshDimDelegate, self).__init__(parent) self.parent = parent self.mdl = mdl def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) editor.installEventFilter(self) return editor def setEditorData(self, comboBox, index): self.modelCombo.addItem(self.tr("2D"), "2") self.modelCombo.addItem(self.tr("3D"), "3") def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] model.setData(index, to_qvariant(value), Qt.DisplayRole) def tr(self, text): """ Translation """ return text
class ParticleBoundaryInteractionDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(ParticleBoundaryInteractionDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.combo_mdl = ComboModel(editor, 1, 1) nature = index.model()._data[index.row()][1] self.dico = index.model().dicoM2V[nature] for k, v in list(self.dico.items()): self.combo_mdl.addItem(v, k) editor.installEventFilter(self) editor.setMinimumWidth(100) return editor def setEditorData(self, comboBox, index): row = index.row() col = index.column() str_model = index.model()._data[row][col] self.combo_mdl.setItem(str_model=str_model) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.combo_mdl.dicoV2M[txt] selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole) def tr(self, text): return text
class BoundaryConditionsFractionView(QWidget, Ui_BoundaryConditionsFraction) : """ Boundary condition for energy """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsFraction.__init__(self) self.setupUi(self) self.__modelFraction = ComboModel(self.comboBoxFraction, 2, 1) self.__modelFraction.addItem(self.tr("Imposed value"), 'dirichlet') self.__modelFraction.addItem(self.tr("Automatic value"), 'automatic') # Connections self.lineEditFraction.textChanged[str].connect(self.__slotFraction) self.comboBoxFraction.activated[str].connect(self.__slotChoiceFraction) validatorFraction = DoubleValidator(self.lineEditFraction, min = 0., max = 1.) validatorFraction.setExclusiveMin(False) validatorFraction.setExclusiveMax(False) self.lineEditFraction.setValidator(validatorFraction) def setup(self, case, fieldId): """ Setup the widget """ self.case = case self.__boundary = None self.__currentField = fieldId
class FieldDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, mdl): super(FieldDelegate, self).__init__(parent) self.parent = parent self.mdl = mdl def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) for fieldId in self.mdl.getFieldIdList(): label = self.mdl.getLabel(fieldId) self.modelCombo.addItem(self.tr(label), label) 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("FieldDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, value, Qt.DisplayRole)
class VarianceDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(VarianceDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) editor.installEventFilter(self) return editor def setEditorData(self, editor, index): editor.setAutoFillBackground(True) l1 = index.model().mdl.getScalarNameList() for label in index.model().mdl.getThermalScalarName(): l1.append(label) for s in index.model().mdl.getScalarsVarianceList(): if s in l1: l1.remove(s) for s in l1: self.modelCombo.addItem(s, s) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] model.setData(index, to_qvariant(value), Qt.DisplayRole) def tr(self, text): """ Translation """ return text
class TurbulenceDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, mdl, dicoM2V, dicoV2M): super(TurbulenceDelegate, 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": turbulence_models = TurbulenceModelsDescription.continuousTurbulenceModels else: carrier = self.mdl.getCarrierField(fieldId) if self.mdl.getPredefinedFlow() == "boiling_flow": turbulence_models = TurbulenceModelsDescription.bubblyFlowsTurbulenceModels elif self.mdl.getPredefinedFlow() == "droplet_flow": turbulence_models = TurbulenceModelsDescription.dropletFlowsTurbulenceModels elif self.mdl.getTurbulenceModel(carrier) != "none" or \ self.mdl.getFieldNature(fieldId) == "solid": turbulence_models = TurbulenceModelsDescription.dispersedTurbulenceModels else: turbulence_models = ["none"] for turb in turbulence_models: self.modelCombo.addItem(self.tr(self.dicoM2V[turb]), turb) 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("TurbulenceDelegate 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)
class BoundaryConditionsWallView(QWidget, Ui_BoundaryConditionsWall): """ Boundary condition for energy """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsWall.__init__(self) self.setupUi(self) # Connections self.comboBoxWallModel.activated[str].connect(self.__slotWall) self.__WallModel = ComboModel(self.comboBoxWallModel, 5, 1) self.__WallModel.addItem(self.tr("adherence"), "adherence") self.__WallModel.addItem(self.tr("friction"), "friction") self.__WallModel.addItem(self.tr("dU2/dn = 0"), "du2_dn") self.__WallModel.addItem(self.tr("dVR/dn = 0"), "dvr_dn") self.__WallModel.addItem(self.tr("droplet friction"), "droplet_friction") def setup(self, case, fieldId): """ Setup the widget """ self.case = case self.__boundary = None self.__currentField = fieldId
class DispersionTurbulentDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, mdl, dicoM2V, dicoV2M): super(DispersionTurbulentDelegate, 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) fielda = index.model().getData(index)[0] fieldb = index.model().getData(index)[1] fieldaId = self.mdl.getFieldId(fielda) fieldbId = self.mdl.getFieldId(fieldb) for model in self.mdl.getAvailableTurbulenteDispersionModelList(fieldaId, fieldbId) : self.modelCombo.addItem(self.tr(self.dicoM2V[model]), model) 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("DispersionTurbulentDelegate 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 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 EnthalpyDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, mdl): super(EnthalpyDelegate, self).__init__(parent) self.parent = parent self.mdl = mdl def createEditor(self, parent, option, index): editor = QComboBox(parent) if self.mdl.getPredefinedFlow() == "free_surface" or \ self.mdl.getPredefinedFlow() == "boiling_flow" or \ self.mdl.getPredefinedFlow() == "droplet_flow": self.modelCombo = ComboModel(editor, 2, 1) self.modelCombo.addItem(self.tr("off"), 'off') self.modelCombo.addItem(self.tr("total enthalpy"), 'total_enthalpy') else: self.modelCombo = ComboModel(editor, 3, 1) self.modelCombo.addItem(self.tr("off"), 'off') self.modelCombo.addItem(self.tr("total enthalpy"), 'total_enthalpy') self.modelCombo.addItem(self.tr("specific enthalpy"), 'specific_enthalpy') 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("EnthalpyDelegate 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 GGDHDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, case): super(GGDHDelegate, self).__init__(parent) self.parent = parent self.case = case def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) editor.installEventFilter(self) return editor def setEditorData(self, editor, index): if GroundwaterModel(self.case).getGroundwaterModel() == "groundwater": self.modelCombo.addItem(self.tr("OFF"), "OFF") else:
class CarrierDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, mdl): super(CarrierDelegate, self).__init__(parent) self.parent = parent self.mdl = mdl 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("off"), 'off') else: for id in self.mdl.getContinuousFieldList(): label = self.mdl.getLabel(id) self.modelCombo.addItem(self.tr(label), label) 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("CarrierDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole) def tr(self, text): return text
class SchemeDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, dicoM2V, dicoV2M): super(SchemeDelegate, self).__init__(parent) self.parent = parent self.dicoM2V = dicoM2V self.dicoV2M = dicoV2M def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 3, 1) self.modelCombo.addItem(self.tr(self.dicoM2V["centered"]), 'centered') self.modelCombo.addItem(self.tr(self.dicoM2V["upwind"]), 'upwind') self.modelCombo.addItem(self.tr(self.dicoM2V["solu"]), 'solu') 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("SchemeDelegate 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)
class LocationDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(LocationDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 4, 1) self.modelCombo.addItem(self.tr("cells"), "cells") self.modelCombo.addItem(self.tr("interior faces"), "internal") self.modelCombo.addItem(self.tr("boundary faces"), "boundary") self.modelCombo.addItem(self.tr("vertices"), "vertices") 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("LocationDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, value, Qt.DisplayRole)
class TypeDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(TypeDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 5, 1) self.modelCombo.addItem(self.tr("H2"), 'H2') self.modelCombo.addItem(self.tr("N2"), 'N2') self.modelCombo.addItem(self.tr("HE"), 'HE') self.modelCombo.addItem(self.tr("O2"), 'O2') self.modelCombo.addItem(self.tr("Air"), 'Air') 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("TypeDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, value, Qt.DisplayRole)
class ParticleBoundaryInteractionDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(ParticleBoundaryInteractionDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.combo_mdl = ComboModel(editor,1,1) nature = index.model()._data[index.row()][1] self.dico = index.model().dicoM2V[nature] for k, v in list(self.dico.items()): self.combo_mdl.addItem(v, k) editor.installEventFilter(self) editor.setMinimumWidth(100) return editor def setEditorData(self, comboBox, index): row = index.row() col = index.column() str_model = index.model()._data[row][col] self.combo_mdl.setItem(str_model=str_model) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.combo_mdl.dicoV2M[txt] selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole) def tr(self, text): return text
class VarianceDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(VarianceDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) editor.installEventFilter(self) return editor def setEditorData(self, editor, index): l1 = index.model().mdl.getScalarNameList() for label in index.model().mdl.getThermalScalarName(): l1.append(label) for s in index.model().mdl.getScalarsVarianceList(): if s in l1: l1.remove(s) for s in l1: self.modelCombo.addItem(s, s) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] model.setData(index, to_qvariant(value), Qt.DisplayRole) def tr(self, text): """ Translation """ return text
class BoundaryConditionsScalarView(QWidget, Ui_BoundaryConditionsScalar): """ Boundary condition for non condensable """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsScalar.__init__(self) self.setupUi(self) # Connections self.comboBoxScalar.activated[str].connect(self.__slotChoiceScalar) self.__Scalarmodel = ComboModel(self.comboBoxScalar, 1, 1) self.comboBoxScalarChoice.activated[str].connect( self.slotScalarTypeChoice) self.scalarChoiceModel = ComboModel(self.comboBoxScalarChoice, 1, 1) self.scalarChoiceModel.addItem(self.tr("Value"), 'dirichlet') self.scalarChoiceModel.addItem(self.tr("Flux"), 'flux') self.lineEditScalar.textChanged[str].connect(self.__slotScalar) validatorScalar = DoubleValidator(self.lineEditScalar) self.lineEditScalar.setValidator(validatorScalar) def setup(self, case, fieldId): """ Setup the widget """ self.case = case self.__boundary = None self.__currentField = fieldId
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 BoundaryConditionsTurbulenceInletView( QWidget, Ui_BoundaryConditionsTurbulenceInletForm): """ Boundary condition for turbulence """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsTurbulenceInletForm.__init__(self) self.setupUi(self) # Connections self.comboBoxTurbulence.activated[str].connect( self.__slotChoiceTurbulence) self.__modelTurbulence = ComboModel(self.comboBoxTurbulence, 3, 1) self.__modelTurbulence.addItem( self.tr("Calculation by hydraulic diameter"), 'hydraulic_diameter') self.__modelTurbulence.addItem( self.tr("Calculation by turbulent intensity"), 'turbulent_intensity') self.__modelTurbulence.addItem(self.tr("Calculation by formula"), 'formula') self.lineEditDiameter.textChanged[str].connect(self.__slotDiam) self.lineEditIntensity.textChanged[str].connect(self.__slotIntensity) self.lineEditDiameterIntens.textChanged[str].connect(self.__slotDiam) self.pushButtonTurb.clicked.connect(self.__slotTurbulenceFormula) validatorDiam = DoubleValidator(self.lineEditDiameter, min=0.) validatorDiam.setExclusiveMin(True) validatorIntensity = DoubleValidator(self.lineEditIntensity, min=0.) self.lineEditDiameter.setValidator(validatorDiam) self.lineEditDiameterIntens.setValidator(validatorDiam) self.lineEditIntensity.setValidator(validatorIntensity) def setup(self, case, fieldId): """ Setup the widget """ self.case = case self.__boundary = None self.__currentField = fieldId
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 UserDimensionDelegate(QItemDelegate): """ Use of a combo box in the table for the user array dimension. """ def __init__(self, parent): super(UserDimensionDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 5, 1) self.modelCombo.addItem(self.tr("1"), "1") self.modelCombo.addItem(self.tr("2"), "2") self.modelCombo.addItem(self.tr("3"), "3") self.modelCombo.addItem(self.tr("6"), "6") self.modelCombo.addItem(self.tr("9"), "9") 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("UserDimensionDelegate 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 GGDHDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, case): super(GGDHDelegate, self).__init__(parent) self.parent = parent self.case = case def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) editor.installEventFilter(self) return editor def setEditorData(self, editor, index): self.modelCombo.addItem(self.tr("SGDH"), "SGDH") if TurbulenceModel(self.case).getTurbulenceModel() == "Rij-epsilon" or \ TurbulenceModel(self.case).getTurbulenceModel() == "Rij-SSG" or \ TurbulenceModel(self.case).getTurbulenceModel() == "Rij-EBRSM": self.modelCombo.addItem(self.tr("GGDH"), "GGDH") self.modelCombo.addItem(self.tr("AFM"), "AFM") self.modelCombo.addItem(self.tr("DFM"), "DFM") def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] model.setData(index, to_qvariant(value), Qt.DisplayRole) 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 BoundaryConditionsWallRadiativeTransferView(QWidget, Ui_BoundaryConditionsWallRadiativeTransferForm): """ """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsWallRadiativeTransferForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() # Create the Page layout. # Combo self.modelRadiative = ComboModel(self.comboBoxRadiative,3,1) self.modelRadiative.addItem(self.tr("Gray or black wall\n"\ " and profile of fixed internal temperature"), 'itpimp') self.modelRadiative.addItem(self.tr("Gray or black wall\n"\ " and profile of fixed external temperature"), 'ipgrno') self.modelRadiative.addItem(self.tr("Gray or black wall\n"\ " and flux of fixed conduction"), 'ifgrno') # Validator validatorZone = IntValidator(self.lineEditZone, min=0) validatorZone.setExclusiveMin(True) self.lineEditZone.setValidator(validatorZone) # Connections self.connect(self.comboBoxRadiative, SIGNAL("activated(const QString&)"), self.slotRadiativeChoice) self.connect(self.lineEditZone, SIGNAL("textChanged(const QString &)"), self.slotZone) self.__case.undoStartGlobal() def showWidget(self, b): """ Show the widget """ if ThermalRadiationModel(self.__case).getRadiativeModel() != "off": label = b.getLabel() self.__boundary = Boundary('radiative_wall', label, self.__case) choice = self.__boundary.getRadiativeChoice() self.modelRadiative.setItem(str_model=choice) if hasattr(self, "modelScalars"): del self.modelScalars self.modelScalars = StandardItemModelScalars(self.__boundary) self.tableViewScalars.setModel(self.modelScalars) self.nb_zone = self.__boundary.getOutputRadiativeZone() self.lineEditZone.setText(str(self.nb_zone)) self.show() else: self.hideWidget() def hideWidget(self): """ Hide all the widget """ self.hide() @pyqtSignature("const QString&") def slotZone(self, text): if self.sender().validator().state == QValidator.Acceptable: nb_zone = from_qvariant(text, int) self.__boundary.setOutputRadiativeZone(nb_zone) return nb_zone @pyqtSignature("const QString&") def slotRadiativeChoice(self, text): cond = self.modelRadiative.dicoV2M[str(text)] log.debug("slotRadiativeChoice cond = %s "%cond) self.__boundary.setRadiativeChoice(cond) self.modelScalars.deleteAll() self.modelScalars = StandardItemModelScalars(self.__boundary) self.tableViewScalars.setModel(self.modelScalars) def tr(self, text): """ Translation """ return text
class DarcyView(QWidget, Ui_DarcyForm): """ Class to open Page. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_DarcyForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = DarcyModel(self.case) # ComboBox self.modelPermeability = ComboModel(self.comboBoxPermeability,2,1) self.modelDiffusion = ComboModel(self.comboBoxDiffusion,2,1) self.modelFlowType = ComboModel(self.comboBoxFlowType,2,1) self.modelCriterion = ComboModel(self.comboBoxCriterion,2,1) self.lineEditGx.setValidator(DoubleValidator(self.lineEditGx)) self.lineEditGy.setValidator(DoubleValidator(self.lineEditGy)) self.lineEditGz.setValidator(DoubleValidator(self.lineEditGz)) self.modelPermeability.addItem(self.tr("isotropic"), 'isotropic') self.modelPermeability.addItem(self.tr("anisotropic"), 'anisotropic') self.modelDiffusion.addItem(self.tr("isotropic"), 'isotropic') self.modelDiffusion.addItem(self.tr("anisotropic"), 'anisotropic') self.modelFlowType.addItem(self.tr("steady"), 'steady') self.modelFlowType.addItem(self.tr("unsteady"), 'unsteady') self.modelCriterion.addItem(self.tr("over pressure"), 'pressure') self.modelCriterion.addItem(self.tr("over velocity"), 'velocity') # Connections self.connect(self.comboBoxPermeability, SIGNAL("activated(const QString&)"), self.slotPermeabilityType) self.connect(self.comboBoxDiffusion, SIGNAL("activated(const QString&)"), self.slotDiffusionType) self.connect(self.comboBoxFlowType, SIGNAL("activated(const QString&)"), self.slotFlowType) self.connect(self.comboBoxCriterion, SIGNAL("activated(const QString&)"), self.slotCriterion) self.connect(self.checkBoxGravity, SIGNAL("clicked()"), self.slotGravity) self.connect(self.lineEditGx, SIGNAL("textChanged(const QString &)"), self.slotGravityX) self.connect(self.lineEditGy, SIGNAL("textChanged(const QString &)"), self.slotGravityY) self.connect(self.lineEditGz, SIGNAL("textChanged(const QString &)"), self.slotGravityZ) self.initializeWidget() self.case.undoStartGlobal() @pyqtSignature("") def initializeWidget(self): """ """ value = self.mdl.getPermeabilityType() self.modelPermeability.setItem(str_model=value) value = self.mdl.getDiffusionType() self.modelDiffusion.setItem(str_model=value) value = self.mdl.getFlowType() self.modelFlowType.setItem(str_model=value) value = self.mdl.getCriterion() self.modelCriterion.setItem(str_model=value) if self.mdl.getGravity() == 'on': self.checkBoxGravity.setChecked(True) self.groupBoxGravity.show() gx, gy, gz = self.mdl.getGravityVector() self.lineEditGx.setText(str(gx)) self.lineEditGy.setText(str(gy)) self.lineEditGz.setText(str(gz)) else: self.checkBoxGravity.setChecked(False) self.groupBoxGravity.hide() @pyqtSignature("const QString&") def slotPermeabilityType(self, text): """ Input permeability type : isotrop or anisotrop. """ mdl = self.modelPermeability.dicoV2M[str(text)] self.mdl.setPermeabilityType(mdl) @pyqtSignature("const QString&") def slotDiffusionType(self, text): """ Input viscosity type : isotrop or anisotrop. """ mdl = self.modelDiffusion.dicoV2M[str(text)] self.mdl.setDiffusionType(mdl) @pyqtSignature("const QString&") def slotFlowType(self, text): """ Input flow type : steady or unsteady. """ mdl = self.modelFlowType.dicoV2M[str(text)] self.mdl.setFlowType(mdl) @pyqtSignature("const QString&") def slotCriterion(self, text): """ Input convergence criterion of Newton scheme. """ mdl = self.modelCriterion.dicoV2M[str(text)] self.mdl.setCriterion(mdl) @pyqtSignature("") def slotGravity(self): """ Input if gravity is taken into account or not """ if self.checkBoxGravity.isChecked(): self.mdl.setGravity('on') self.groupBoxGravity.show() gx, gy, gz = self.mdl.getGravityVector() self.lineEditGx.setText(str(gx)) self.lineEditGy.setText(str(gy)) self.lineEditGz.setText(str(gz)) else: self.mdl.setGravity('off') @pyqtSignature("const QString&") def slotGravityX(self, text): """ Input component X for gravity vector """ if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setGravityVector("axis_x", val) @pyqtSignature("const QString&") def slotGravityY(self, text): """ Input component Y for gravity vector """ if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setGravityVector("axis_y", val) @pyqtSignature("const QString&") def slotGravityZ(self, text): """ Input component Z for gravity vector """ if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setGravityVector("axis_z", val) def tr(self, text): """ Translation """ return text
class BoundaryConditionsVelocityInletView(QWidget, Ui_BoundaryConditionsVelocityInletForm): """ Boundary condition for velocity in inlet, without particular physics. """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsVelocityInletForm.__init__(self) self.setupUi(self) self.thermodynamic_list = ['Pressure', 'Density', 'Temperature', 'Energy'] def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.mdl = CompressibleModel(self.__case) self.gas = GasCombustionModel(self.__case) # Connections self.connect(self.comboBoxVelocity, SIGNAL("activated(const QString&)"), self.__slotChoiceVelocity) self.connect(self.lineEditVelocity, SIGNAL("textChanged(const QString &)"), self.__slotVelocityValue) self.connect(self.comboBoxDirection, SIGNAL("activated(const QString&)"), self.__slotChoiceDirection) self.connect(self.lineEditDirectionX, SIGNAL("textChanged(const QString &)"), self.__slotDirX) self.connect(self.lineEditDirectionY, SIGNAL("textChanged(const QString &)"), self.__slotDirY) self.connect(self.lineEditDirectionZ, SIGNAL("textChanged(const QString &)"), self.__slotDirZ) self.connect(self.comboBoxTypeInlet, SIGNAL("activated(const QString&)"), self.__slotInletType) self.connect(self.checkBoxPressure, SIGNAL("clicked()"), self.__slotPressure) self.connect(self.checkBoxDensity, SIGNAL("clicked()"), self.__slotDensity) self.connect(self.checkBoxTemperature, SIGNAL("clicked()"), self.__slotTemperature) self.connect(self.checkBoxEnergy, SIGNAL("clicked()"), self.__slotEnergy) self.connect(self.lineEditPressure, SIGNAL("textChanged(const QString &)"), self.__slotPressureValue) self.connect(self.lineEditDensity, SIGNAL("textChanged(const QString &)"), self.__slotDensityValue) self.connect(self.lineEditTotalPressure, SIGNAL("textChanged(const QString &)"), self.__slotTotalPressure) self.connect(self.lineEditTotalEnthalpy, SIGNAL("textChanged(const QString &)"), self.__slotTotalEnthalpy) self.connect(self.lineEditTemperature, SIGNAL("textChanged(const QString &)"), self.__slotTemperatureValue) self.connect(self.lineEditEnergy, SIGNAL("textChanged(const QString &)"), self.__slotEnergyValue) self.connect(self.comboBoxTypeInletGasComb, SIGNAL("activated(const QString&)"), self.__slotInletTypeGasComb) self.connect(self.lineEditTemperatureGasComb, SIGNAL("textChanged(const QString &)"), self.__slotTemperatureGasComb) self.connect(self.lineEditFraction, SIGNAL("textChanged(const QString &)"), self.__slotMeanMixtureFraction) # Combo models self.modelVelocity = ComboModel(self.comboBoxVelocity, 6, 1) self.modelVelocity.addItem(self.tr("norm"), 'norm') self.modelVelocity.addItem(self.tr("mass flow rate"), 'flow1') self.modelVelocity.addItem(self.tr("volumic flow rate"), 'flow2') self.modelVelocity.addItem(self.tr("norm (user law)"), 'norm_formula') self.modelVelocity.addItem(self.tr("mass flow rate (user law)"), 'flow1_formula') self.modelVelocity.addItem(self.tr("volumic flow rate (user law)"), 'flow2_formula') self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("normal direction to the inlet"), 'normal') self.modelDirection.addItem(self.tr("specified coordinates"), 'coordinates') self.modelDirection.addItem(self.tr("user profile"), 'formula') self.modelTypeInlet = ComboModel(self.comboBoxTypeInlet, 2, 1) self.modelTypeInlet.addItem(self.tr("imposed inlet"), 'imposed_inlet') self.modelTypeInlet.addItem(self.tr("subsonic inlet (imposed total pressure and total enthalpy)"), 'subsonic_inlet_PH') self.modelTypeInletGasComb = ComboModel(self.comboBoxTypeInletGasComb, 2, 1) model = self.gas.getGasCombustionModel() if model == 'lwp' or model =='ebu': self.modelTypeInletGasComb.addItem(self.tr("Unburned gas"), 'unburned') self.modelTypeInletGasComb.addItem(self.tr("Burned gas"), 'burned') elif model == 'd3p': self.modelTypeInletGasComb.addItem(self.tr("Oxydant"), 'oxydant') self.modelTypeInletGasComb.addItem(self.tr("Fuel"), 'fuel') # Validators validatorVelocity = DoubleValidator(self.lineEditVelocity) validatorX = DoubleValidator(self.lineEditDirectionX) validatorY = DoubleValidator(self.lineEditDirectionY) validatorZ = DoubleValidator(self.lineEditDirectionZ) validatorP = DoubleValidator(self.lineEditPressure, min = 0.0) validatorD = DoubleValidator(self.lineEditDensity, min = 0.0) validatorT = DoubleValidator(self.lineEditTemperature, min = 0.0) validatorE = DoubleValidator(self.lineEditEnergy, min = 0.0) validatorP2 = DoubleValidator(self.lineEditTotalPressure, min = 0.0) validatorH2 = DoubleValidator(self.lineEditTotalEnthalpy, min = 0.0) validatorTemp = DoubleValidator(self.lineEditTemperatureGasComb, min=0.) validatorFrac = DoubleValidator(self.lineEditFraction, min=0., max=1.) # Apply validators self.lineEditVelocity.setValidator(validatorVelocity) self.lineEditDirectionX.setValidator(validatorX) self.lineEditDirectionY.setValidator(validatorY) self.lineEditDirectionZ.setValidator(validatorZ) self.lineEditPressure.setValidator(validatorP) self.lineEditDensity.setValidator(validatorD) self.lineEditTemperature.setValidator(validatorT) self.lineEditEnergy.setValidator(validatorE) self.lineEditTotalPressure.setValidator(validatorP2) self.lineEditTotalEnthalpy.setValidator(validatorH2) self.lineEditTemperatureGasComb.setValidator(validatorTemp) self.lineEditFraction.setValidator(validatorFrac) self.connect(self.pushButtonVelocityFormula, SIGNAL("clicked()"), self.__slotVelocityFormula) self.connect(self.pushButtonDirectionFormula, SIGNAL("clicked()"), self.__slotDirectionFormula) self.__case.undoStartGlobal() def showWidget(self, boundary): """ Show the widget """ self.__boundary = boundary # Initialize velocity choice = self.__boundary.getVelocityChoice() self.modelVelocity.setItem(str_model=choice) self.__updateLabel() if choice[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) self.lineEditVelocity.setEnabled(False) else: self.pushButtonVelocityFormula.setEnabled(False) self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) # Initialize direction choice = self.__boundary.getDirectionChoice() self.modelDirection.setItem(str_model=choice) text = self.modelDirection.dicoM2V[choice] if choice == "formula": self.pushButtonDirectionFormula.setEnabled(True) self.frameDirectionCoordinates.hide() elif choice == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif choice == "normal": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.hide() self.initialize() def initialize(self): """ Initialize widget for compressible """ self.comboBoxVelocity.show() self.lineEditVelocity.show() self.labelUnitVelocity.show() self.pushButtonVelocityFormula.show() # Initialize thermodynamic value if self.mdl.getCompressibleModel() != 'off': inlet_type = self.__boundary.getInletType() self.modelTypeInlet.setItem(str_model = inlet_type) self.__boundary.setInletType(inlet_type) if inlet_type == 'imposed_inlet': self.groupBoxThermodynamic.show() self.frameDensity.hide() for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setChecked(False) __checkBox.setEnabled(False) __lineEdit.setEnabled(False) __lineEdit.clear() box_list = self.__boundary.getCheckedBoxList() if len(box_list) == 0: for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) elif len(box_list) == 1: for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) box = box_list[0] if box == 'Temperature': self.checkBoxEnergy.setEnabled(False) elif box == 'Energy': self.checkBoxTemperature.setEnabled(False) __checkBox = getattr(self, "checkBox" + box) __checkBox.setChecked(True) __lineEdit = getattr(self, "lineEdit" + box) __lineEdit.setEnabled(True) v1 = self.__boundary.getListValue()[0] __lineEdit.setText(str(v1)) elif len(box_list) == 2: v1,v2 = self.__boundary.getListValue() for name in box_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) __checkBox.setChecked(True) __lineEdit.setEnabled(True) if v1 >= 0.: __lineEdit.setText(str(v1)) else: __lineEdit.setText(str(v2)) v1 = -1. elif inlet_type == 'subsonic_inlet_PH': self.comboBoxVelocity.hide() self.lineEditVelocity.hide() self.labelUnitVelocity.hide() self.pushButtonVelocityFormula.hide() self.groupBoxThermodynamic.hide() self.frameDensity.show() pressure = self.__boundary.getThermoValue('total_pressure') self.lineEditTotalPressure.setText(str(pressure)) enthalpy = self.__boundary.getThermoValue('enthalpy') self.lineEditTotalEnthalpy.setText(str(enthalpy)) else: self.groupBoxCompressible.hide() # Initialize temperature and mean mixture fraction model = self.gas.getGasCombustionModel() if model != 'off': self.groupBoxGasCombustion.show() inlet_type = self.__boundary.getInletGasCombustionType() self.modelTypeInletGasComb.setItem(str_model = inlet_type) if model == 'd3p': self.lineEditTemperatureGasComb.hide() self.labelTemperature_2.hide() self.labelUnitTemp.hide() self.lineEditFraction.setEnabled(False) f = self.__boundary.setMeanMixtureFraction(1) self.lineEditFraction.setText(str(1) if inlet_type == 'oxydant' else str(0)) else : self.lineEditTemperatureGasComb.show() self.labelTemperature_2.show() self.labelUnitTemp.show() t = self.__boundary.getGasCombustionTemperature() self.lineEditTemperatureGasComb.setText(str(t)) self.lineEditFraction.setEnabled(True) f = self.__boundary.getMeanMixtureFraction() self.lineEditFraction.setText(str(f)) else: self.groupBoxGasCombustion.hide() self.show() def hideWidget(self): """ Hide all """ self.hide() @pyqtSignature("const QString&") def __slotChoiceVelocity(self, text): """ Private slot. Input the velocity boundary type choice (norm, ). @type text: C{QString} @param text: velocity boundary type choice. """ c = self.modelVelocity.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setVelocityChoice(c) if c[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) setGreenColor(self.pushButtonVelocityFormula, True) self.lineEditVelocity.setEnabled(False) self.lineEditVelocity.setText("") else: self.pushButtonVelocityFormula.setEnabled(False) setGreenColor(self.pushButtonVelocityFormula, False) self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) self.__updateLabel() def __updateLabel(self): """ Update the unit for the velocity specification. """ c = self.__boundary.getVelocityChoice() if c in ('norm', 'norm_formula'): self.labelUnitVelocity.setText(str('m/s')) elif c in ('flow1', 'flow1_formula'): self.labelUnitVelocity.setText(str('kg/s')) elif c in ('flow2', 'flow2_formula'): self.labelUnitVelocity.setText(str('m<sup>3</sup>/s')) @pyqtSignature("const QString&") def __slotVelocityValue(self, text): """ Private slot. New value associated to the velocity boundary type. @type text: C{QString} @param text: value """ if self.sender().validator().state == QValidator.Acceptable: v = from_qvariant(text, float) self.__boundary.setVelocity(v) @pyqtSignature("") def __slotVelocityFormula(self): """ """ exp = self.__boundary.getVelocity() c = self.__boundary.getVelocityChoice() if c == 'norm_formula': exa = "u_norm = 1.0;" req = [('u_norm', 'Norm of the velocity')] elif c == 'flow1_formula': exa = "q_m = 1.0;" req = [('q_m', 'mass flow rate')] elif c == 'flow2_formula': exa = "q_v = 1.0;" req = [('q_v', 'volumic flow rate')] sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] 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("slotFormulaVelocity -> %s" % str(result)) self.__boundary.setVelocity(result) setGreenColor(self.pushButtonVelocityFormula, False) @pyqtSignature("const QString&") def __slotChoiceDirection(self, text): """ Input the direction type choice. """ c = self.modelDirection.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setDirectionChoice(c) if c == "formula": self.pushButtonDirectionFormula.setEnabled(True) setGreenColor(self.pushButtonDirectionFormula, True) self.frameDirectionCoordinates.hide() elif c == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) setGreenColor(self.pushButtonDirectionFormula, False) self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif c == "normal": self.pushButtonDirectionFormula.setEnabled(False) setGreenColor(self.pushButtonDirectionFormula, False) self.frameDirectionCoordinates.hide() @pyqtSignature("const QString&") def __slotDirX(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_x', value) @pyqtSignature("const QString&") def __slotDirY(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_y', value) @pyqtSignature("const QString&") def __slotDirZ(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_z', value) @pyqtSignature("") def __slotDirectionFormula(self): """ """ exp = self.__boundary.getDirection('direction_formula') req = [('dir_x', 'Direction of the flow along X'), ('dir_y', 'Direction of the flow along Y'), ('dir_z', 'Direction of the flow along Z')] exa = "dir_x = 3.0;\ndir_y = 1.0;\ndir_z = 0.0;\n" sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] 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("slotFormulaDirection -> %s" % str(result)) self.__boundary.setDirection('direction_formula', result) setGreenColor(self.pushButtonDirectionFormula, False) @pyqtSignature("const QString&") def __slotInletType(self, text): """ INPUT inlet type : 'oxydant'/'fuel' or 'burned'/'unburned' """ value = self.modelTypeInlet.dicoV2M[str(text)] log.debug("__slotInletType value = %s " % value) self.__boundary.setInletType(value) self.initialize() @pyqtSignature("") def __slotPressure(self): """ Pressure selected or not for the initialisation. """ if self.checkBoxPressure.isChecked(): self.__boundary.setThermoStatus('pressure', "on") else: self.__boundary.setThermoStatus('pressure', "off") self.initialize() @pyqtSignature("") def __slotDensity(self): """ Density selected or not for the initialisation. """ if self.checkBoxDensity.isChecked(): self.__boundary.setThermoStatus('density', "on") else: self.__boundary.setThermoStatus('density', "off") self.initialize() @pyqtSignature("") def __slotTemperature(self): """ Temperature selected or not for the initialisation. """ if self.checkBoxTemperature.isChecked(): self.__boundary.setThermoStatus('temperature', "on") else: self.__boundary.setThermoStatus('temperature', "off") self.initialize() @pyqtSignature("") def __slotEnergy(self): """ Energy selected or not for the initialisation. """ if self.checkBoxEnergy.isChecked(): self.__boundary.setThermoStatus('energy', "on") else: self.__boundary.setThermoStatus('energy', "off") self.initialize() @pyqtSignature("const QString&") def __slotPressureValue(self, text): """ INPUT inlet Pressure """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('pressure', t) @pyqtSignature("const QString&") def __slotDensityValue(self, text): """ INPUT inlet Density """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('density', t) @pyqtSignature("const QString&") def __slotTemperatureValue(self, text): """ INPUT inlet Temperature """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('temperature', t) @pyqtSignature("const QString&") def __slotEnergyValue(self, text): """ INPUT inlet Energy """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('energy', t) @pyqtSignature("const QString&") def __slotTotalPressure(self, text): """ INPUT inlet total pressure """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('total_pressure', t) @pyqtSignature("const QString&") def __slotTotalEnthalpy(self, text): """ INPUT inlet total enthalpy """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('enthalpy', t) @pyqtSignature("const QString&") def __slotTemperatureGasComb(self, text): """ INPUT inlet temperature """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setGasCombustionTemperature(t) @pyqtSignature("const QString&") def __slotMeanMixtureFraction(self, text): """ INPUT inlet mean mixutre fraction """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setMeanMixtureFraction(f) @pyqtSignature("const QString&") def __slotInletTypeGasComb(self, text): """ INPUT inlet type : 'oxydant'/'fuel' or 'burned'/'unburned' """ value = self.modelTypeInletGasComb.dicoV2M[str(text)] log.debug("__slotInletTypeGasComb value = %s " % value) self.__boundary.setInletGasCombustionType(value) self.initialize() def tr(self, text): """ Translation """ return text
class MobileMeshView(QWidget, Ui_MobileMeshForm): """ Class to open Page. """ viscosity_iso = """# Viscosity of the mesh allows to control the deformation # of the mesh. Viscosity must be greater than zero. # It could be isotropic (the same for all directions) or # orthotropic. # # In the following example, a hight value of viscosity # is imposed around a mobile cylinder. # The viscosity is specfied for all cells # on the initial mesh before any deformation. # xr2 = 1.5^2; xcen = 5.0; ycen = 0.; zcen = 6.0; xray2 = (x-xcen)^2 + (y-ycen)^2 + (z-zcen)^2; mesh_viscosity_1 = 1; if (xray2 < xr2) mesh_viscosity_1 = 1e10; """ viscosity_ortho = """# Viscosity of the mesh allows to control the deformation # of the mesh. Viscosity must be greater than zero. # It could be isotropic (the same for all directions) or # orthotropic. # # In the following example, a hight value of viscosity # is imposed around a mobile cylinder. # The viscosity is specfied for all cells # on the initial mesh before any deformation. # xr2 = 1.5^2; xcen = 5.0; ycen = 0.; zcen = 6.0; xray2 = (x-xcen)^2 + (y-ycen)^2 + (z-zcen)^2; mesh_viscosity_1 = 1; mesh_viscosity_2 = 1; mesh_viscosity_3 = 1; if (xray2 < xr2) { mesh_viscosity_1 = 1e10; mesh_viscosity_2 = 1e10; mesh_viscosity_3 = 1e10; } """ def __init__(self, parent, case, browser): """ Constructor """ QWidget.__init__(self, parent) Ui_MobileMeshForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = MobileMeshModel(self.case) self.browser = browser # Combo model VISCOSITY self.modelVISCOSITY = ComboModel(self.comboBoxVISCOSITY,2,1) self.modelVISCOSITY.addItem(self.tr("isotropic"), 'isotrop') self.modelVISCOSITY.addItem(self.tr("orthotropic"), 'orthotrop') # Connections self.connect(self.groupBoxALE, SIGNAL("clicked(bool)"), self.slotMethod) self.connect(self.lineEditNALINF, SIGNAL("textChanged(const QString &)"), self.slotNalinf) self.connect(self.comboBoxVISCOSITY, SIGNAL("activated(const QString&)"), self.slotViscosityType) self.connect(self.pushButtonFormula, SIGNAL("clicked(bool)"), self.slotFormula) # Validators validatorNALINF = IntValidator(self.lineEditNALINF, min=0) self.lineEditNALINF.setValidator(validatorNALINF) if self.mdl.getMethod() == 'on': self.groupBoxALE.setChecked(True) checked = True else: self.groupBoxALE.setChecked(False) checked = False self.slotMethod(checked) # Enable / disable formula state setGreenColor(self.pushButtonFormula, False) self.case.undoStartGlobal() @pyqtSignature("bool") def slotMethod(self, checked): """ Private slot. Activates ALE method. @type checked: C{True} or C{False} @param checked: if C{True}, shows the QGroupBox ALE parameters """ self.groupBoxALE.setFlat(not checked) if checked: self.frame.show() self.mdl.setMethod ("on") nalinf = self.mdl.getSubIterations() self.lineEditNALINF.setText(str(nalinf)) value = self.mdl.getViscosity() self.modelVISCOSITY.setItem(str_model=value) else: self.frame.hide() self.mdl.setMethod("off") setGreenColor(self.pushButtonFormula, True) @pyqtSignature("const QString&") def slotNalinf(self, text): """ Input viscosity type of mesh : isotrop or orthotrop. """ if self.sender().validator().state == QValidator.Acceptable: nalinf = from_qvariant(text, int) self.mdl.setSubIterations(nalinf) @pyqtSignature("const QString&") def slotViscosityType(self, text): """ Input viscosity type of mesh : isotrop or orthotrop. """ self.viscosity_type = self.modelVISCOSITY.dicoV2M[str(text)] visco = self.viscosity_type self.mdl.setViscosity(visco) setGreenColor(self.pushButtonFormula, True) return visco @pyqtSignature("const QString&") def slotFormula(self, text): """ Run formula editor. """ exp = self.mdl.getFormula() if self.mdl.getViscosity() == 'isotrop': if not exp: exp = "mesh_viscosity_1 = 1;" req = [('mesh_viscosity_1', 'mesh viscosity')] exa = MobileMeshView.viscosity_iso else: if not exp: exp = "mesh_viscosity_1 = 1;\nmesh_viscosity_2 = 1;\nmesh_viscosity_3 = 1;" req = [('mesh_viscosity_1', 'mesh viscosity X'), ('mesh_viscosity_2', 'mesh viscosity Y'), ('mesh_viscosity_3', 'mesh viscosity Z')] exa = MobileMeshView.viscosity_ortho symb = [('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, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = symb, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMobileMeshView -> %s" % str(result)) self.mdl.setFormula(result) setGreenColor(self.pushButtonFormula, False) def tr(self, text): """ Translation """ return text
class DarcyLawView(QWidget, Ui_DarcyLawForm): def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_DarcyLawForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = DarcyLawModel(self.case) self.list_scalars = [] self.m_sca = DefineUserScalarsModel(self.case) for s in self.m_sca.getUserScalarNameList(): self.list_scalars.append((s, self.tr("Additional scalar"))) # Create the Page layout. # Model and QTreeView for Head Losses self.modelDarcyLaw = StandardItemModelDarcyLaw() self.treeView.setModel(self.modelDarcyLaw) # Combo model self.modelDarcyLawType = ComboModel(self.comboBoxType, 2, 1) self.modelDarcyLawType.addItem(self.tr("User law"), 'user') self.modelDarcyLawType.addItem(self.tr("Van Genuchten law"), 'VanGenuchten') self.modelNameDiff = ComboModel(self.comboBoxNameDiff,1,1) self.modelDiff = ComboModel(self.comboBoxDiff, 2, 1) self.modelDiff.addItem(self.tr('constant'), 'constant') self.modelDiff.addItem(self.tr('variable'), 'variable') # Set up validators self.lineEditKs.setValidator(DoubleValidator(self.lineEditKs)) self.lineEditThetas.setValidator(DoubleValidator(self.lineEditThetas)) self.lineEditThetar.setValidator(DoubleValidator(self.lineEditThetar)) self.lineEditN.setValidator(DoubleValidator(self.lineEditN)) self.lineEditL.setValidator(DoubleValidator(self.lineEditL)) self.lineEditAlpha.setValidator(DoubleValidator(self.lineEditAlpha)) self.lineEditLongitudinal.setValidator(DoubleValidator(self.lineEditLongitudinal)) self.lineEditTransverse.setValidator(DoubleValidator(self.lineEditTransverse)) self.scalar = "" scalar_list = self.m_sca.getUserScalarNameList() for s in self.m_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for scalar in scalar_list: self.modelNameDiff.addItem(scalar) # Connections self.connect(self.treeView, SIGNAL("clicked(const QModelIndex &)"), self.slotSelectDarcyLawZones) self.connect(self.comboBoxType, SIGNAL("activated(const QString&)"), self.slotDarcyLaw) self.connect(self.lineEditKs, SIGNAL("textChanged(const QString &)"), self.slotKs) self.connect(self.lineEditThetas, SIGNAL("textChanged(const QString &)"), self.slotThetas) self.connect(self.lineEditThetar, SIGNAL("textChanged(const QString &)"), self.slotThetar) self.connect(self.lineEditN, SIGNAL("textChanged(const QString &)"), self.slotN) self.connect(self.lineEditL, SIGNAL("textChanged(const QString &)"), self.slotL) self.connect(self.lineEditAlpha, SIGNAL("textChanged(const QString &)"), self.slotAlpha) self.connect(self.lineEditLongitudinal, SIGNAL("textChanged(const QString &)"), self.slotLongitudinal) self.connect(self.lineEditTransverse, SIGNAL("textChanged(const QString &)"), self.slotTransverse) self.connect(self.pushButtonUserLaw, SIGNAL("clicked()"), self.slotFormula) self.connect(self.comboBoxNameDiff, SIGNAL("activated(const QString&)"), self.slotNameDiff) self.connect(self.comboBoxDiff, SIGNAL("activated(const QString&)"), self.slotStateDiff) self.connect(self.pushButtonDiff, SIGNAL("clicked()"), self.slotFormulaDiff) # 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.modelDarcyLaw.insertItem(Lab, NamLoc[0],NamLoc[1]) self.forgetStandardWindows() self.case.undoStartGlobal() @pyqtSignature("const QModelIndex&") def slotSelectDarcyLawZones(self, index): label, name, local = self.modelDarcyLaw.getItem(index.row()) if hasattr(self, "modelScalars"): del self.modelScalars log.debug("slotSelectDarcyLawZones label %s " % label ) self.groupBoxType.show() choice = self.mdl.getDarcyLawModel(name) self.modelDarcyLawType.setItem(str_model=choice) if choice == "user": self.groupBoxVanGenuchten.hide() self.groupBoxUser.show() setGreenColor(self.pushButtonUserLaw, True) else: self.groupBoxVanGenuchten.show() self.groupBoxUser.hide() self.initializeVanGenuchten(name) if DarcyModel(self.case).getDiffusionType() == 'anisotropic': self.groupBoxAnisotropicDiffusion.show() value = self.mdl.getDiffusionCoefficient(name, "longitudinal") self.lineEditLongitudinal.setText(str(value)) value = self.mdl.getDiffusionCoefficient(name, "transverse") self.lineEditTransverse.setText(str(value)) if self.scalar == "": self.groupBoxDiff.hide() else : self.groupBoxDiff.show() diff_choice = self.mdl.getScalarDiffusivityChoice(self.scalar, name) self.modelDiff.setItem(str_model=diff_choice) self.modelNameDiff.setItem(str_model=str(self.scalar)) if diff_choice != 'variable': self.pushButtonDiff.setEnabled(False) setGreenColor(self.pushButtonDiff, False) else: self.pushButtonDiff.setEnabled(True) setGreenColor(self.pushButtonDiff, True) # force to variable property self.comboBoxDiff.setEnabled(False) self.entriesNumber = index.row() def initializeVanGenuchten(self, name): """ initialize variables for groupBoxVanGenuchten """ value = self.mdl.getValue(name, "ks") self.lineEditKs.setText(str(value)) value = self.mdl.getValue(name, "thetas") self.lineEditThetas.setText(str(value)) value = self.mdl.getValue(name, "thetar") self.lineEditThetar.setText(str(value)) value = self.mdl.getValue(name, "n") self.lineEditN.setText(str(value)) value = self.mdl.getValue(name, "l") self.lineEditL.setText(str(value)) value = self.mdl.getValue(name, "alpha") self.lineEditAlpha.setText(str(value)) def forgetStandardWindows(self): """ For forget standard windows """ self.groupBoxType.hide() self.groupBoxUser.hide() self.groupBoxVanGenuchten.hide() self.groupBoxAnisotropicDiffusion.hide() self.groupBoxDiff.hide() @pyqtSignature("const QString &") def slotDarcyLaw(self, text): """ Method to call 'getState' with correct arguements for 'rho' """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) choice = self.modelDarcyLawType.dicoV2M[str(text)] self.mdl.setDarcyLawModel(name, choice) if choice == "user": self.groupBoxVanGenuchten.hide() self.groupBoxUser.show() setGreenColor(self.pushButtonUserLaw, True) else: self.groupBoxVanGenuchten.show() self.groupBoxUser.hide() self.initializeVanGenuchten(name) @pyqtSignature("const QString&") def slotKs(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "ks", val) @pyqtSignature("const QString&") def slotThetas(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "thetas", val) @pyqtSignature("const QString&") def slotThetar(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "thetar", val) @pyqtSignature("const QString&") def slotN(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "n", val) @pyqtSignature("const QString&") def slotL(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "l", val) @pyqtSignature("const QString&") def slotAlpha(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "alpha", val) @pyqtSignature("const QString&") def slotLongitudinal(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setDiffusionCoefficient(name, "longitudinal", val) @pyqtSignature("const QString&") def slotTransverse(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setDiffusionCoefficient(name, "transverse", val) @pyqtSignature("") def slotFormula(self): """ User formula for darcy functions """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) exp = self.mdl.getDarcyLawFormula(name) if exp == None: exp = self.getDefaultDarcyLawFormula(choice) if DarcyModel(self.case).getPermeabilityType() == 'anisotropic': req = [('capacity', 'Capacity'), ('saturation', 'Saturation'), ('permeability[XX]', 'Permeability'), ('permeability[YY]', 'Permeability'), ('permeability[ZZ]', 'Permeability'), ('permeability[XY]', 'Permeability'), ('permeability[XZ]', 'Permeability'), ('permeability[YZ]', 'Permeability')] else: req = [('capacity', 'Capacity'), ('saturation', 'Saturation'), ('permeability', 'Permeability')] exa = """#example: \n""" + self.mdl.getDefaultDarcyLawFormula() sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotFormula -> %s" % str(result)) self.mdl.setDarcyLawFormula(name, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString &") def slotNameDiff(self, text): """ Method to set the variance scalar choosed """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) choice = self.modelNameDiff.dicoV2M[str(text)] log.debug("slotStateDiff -> %s" % (text)) self.scalar = str(text) self.modelDiff.setItem(str_model=self.mdl.getScalarDiffusivityChoice(self.scalar, name)) setGreenColor(self.pushButtonDiff, True) @pyqtSignature("const QString &") def slotStateDiff(self, text): """ Method to set diffusion choice for the coefficient """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) choice = self.modelDiff.dicoV2M[str(text)] log.debug("slotStateDiff -> %s" % (text)) if choice != 'variable': self.pushButtonDiff.setEnabled(False) setGreenColor(self.pushButtonDiff, False) else: self.pushButtonDiff.setEnabled(True) setGreenColor(self.pushButtonDiff, True) self.mdl.setScalarDiffusivityChoice(self.scalar, name, choice) @pyqtSignature("") def slotFormulaDiff(self): """ User formula for the diffusion coefficient """ label, namesca, local = self.modelDarcyLaw.getItem(self.entriesNumber) name = self.m_sca.getScalarDiffusivityName(self.scalar) exp = self.mdl.getDiffFormula(self.scalar, namesca) delay_name = str(self.scalar) + "_delay" req = [(str(name), str(self.scalar) + ' diffusion coefficient'), (delay_name, str(self.scalar)+ ' delay')] exa = '' sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate'), ('saturation', 'saturation')] sym.append((str(self.scalar),str(self.scalar))) 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("slotFormulaDiff -> %s" % str(result)) self.mdl.setDiffFormula(self.scalar, namesca, result) setGreenColor(self.pushButtonDiff, False) def tr(self, text): """ Translation """ return text
class BoundaryConditionsScalarsView(QWidget, Ui_BoundaryConditionsScalarsForm): """ """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsScalarsForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.connect(self.lineEditValueThermal, SIGNAL("textChanged(const QString &)"), self.slotValueThermal) self.connect(self.lineEditValueSpecies, SIGNAL("textChanged(const QString &)"), self.slotValueSpecies) self.connect(self.lineEditValueMeteo, SIGNAL("textChanged(const QString &)"), self.slotValueMeteo) self.connect(self.lineEditExThermal, SIGNAL("textChanged(const QString &)"), self.slotExThermal) self.connect(self.lineEditExSpecies, SIGNAL("textChanged(const QString &)"), self.slotExSpecies) self.connect(self.lineEditExMeteo, SIGNAL("textChanged(const QString &)"), self.slotExMeteo) self.connect(self.pushButtonThermal, SIGNAL("clicked()"), self.slotThermalFormula) self.connect(self.pushButtonSpecies, SIGNAL("clicked()"), self.slotSpeciesFormula) self.connect(self.pushButtonMeteo, SIGNAL("clicked()"), self.slotMeteoFormula) self.connect(self.comboBoxThermal, SIGNAL("activated(const QString&)"), self.slotThermalChoice) self.connect(self.comboBoxTypeThermal, SIGNAL("activated(const QString&)"), self.slotThermalTypeChoice) self.connect(self.comboBoxSpecies, SIGNAL("activated(const QString&)"), self.slotSpeciesChoice) self.connect(self.comboBoxTypeSpecies, SIGNAL("activated(const QString&)"), self.slotSpeciesTypeChoice) self.connect(self.comboBoxMeteo, SIGNAL("activated(const QString&)"), self.slotMeteoChoice) self.connect(self.comboBoxTypeMeteo, SIGNAL("activated(const QString&)"), self.slotMeteoTypeChoice) ## Validators validatorValueThermal = DoubleValidator(self.lineEditValueThermal) validatorValueSpecies = DoubleValidator(self.lineEditValueSpecies) validatorValueMeteo = DoubleValidator(self.lineEditValueMeteo) validatorExThermal = DoubleValidator(self.lineEditExThermal) validatorExSpecies = DoubleValidator(self.lineEditExSpecies) validatorExMeteo = DoubleValidator(self.lineEditExMeteo) self.lineEditValueThermal.setValidator(validatorValueThermal) self.lineEditValueSpecies.setValidator(validatorValueSpecies) self.lineEditValueMeteo.setValidator(validatorValueMeteo) self.lineEditExThermal.setValidator(validatorExThermal) self.lineEditExSpecies.setValidator(validatorExSpecies) self.lineEditExMeteo.setValidator(validatorExMeteo) self.__case.undoStartGlobal() def __setBoundary(self, boundary): """ Set the current boundary """ self.__boundary = boundary self.nature = boundary.getNature() self.therm = ThermalScalarModel(self.__case) self.sca_mo = DefineUserScalarsModel(self.__case) self.comp = CompressibleModel(self.__case) self.atm = AtmosphericFlowsModel(self.__case) self.modelTypeThermal = ComboModel(self.comboBoxTypeThermal, 1, 1) self.modelTypeSpecies = ComboModel(self.comboBoxTypeSpecies, 1, 1) self.modelTypeMeteo = ComboModel(self.comboBoxTypeMeteo, 1, 1) self.modelTypeThermal.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelTypeSpecies.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelTypeMeteo.addItem( self.tr("Prescribed value"), 'dirichlet') self.modelTypeThermal.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelTypeSpecies.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelTypeMeteo.addItem( self.tr("Prescribed value (user law)"), 'dirichlet_formula') if self.nature == 'outlet': self.modelTypeThermal.addItem(self.tr("Prescribed flux"), 'neumann') self.modelTypeSpecies.addItem(self.tr("Prescribed flux"), 'neumann') self.modelTypeMeteo.addItem( self.tr("Prescribed flux"), 'neumann') elif self.nature == 'wall': self.modelTypeThermal.addItem(self.tr("Prescribed flux"), 'neumann') self.modelTypeSpecies.addItem(self.tr("Prescribed flux"), 'neumann') self.modelTypeMeteo.addItem( self.tr("Prescribed flux"), 'neumann') self.modelTypeThermal.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') self.modelTypeSpecies.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') self.modelTypeMeteo.addItem( self.tr("Prescribed flux (user law)"), 'neumann_formula') self.modelTypeThermal.addItem(self.tr("Exchange coefficient"), 'exchange_coefficient') self.modelTypeSpecies.addItem(self.tr("Exchange coefficient"), 'exchange_coefficient') self.modelTypeMeteo.addItem( self.tr("Exchange coefficient"), 'exchange_coefficient') self.modelTypeThermal.addItem(self.tr("Exchange coefficient (user law)"), 'exchange_coefficient_formula') self.modelTypeSpecies.addItem(self.tr("Exchange coefficient (user law)"), 'exchange_coefficient_formula') self.modelTypeMeteo.addItem( self.tr("Exchange coefficient (user law)"), 'exchange_coefficient_formula') self.species = "" self.species_list = self.sca_mo.getUserScalarNameList() for s in self.sca_mo.getScalarsVarianceList(): if s in self.species_list: self.species_list.remove(s) self.species = "" if self.species_list != []: self.groupBoxSpecies.show() self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) 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) else: self.groupBoxSpecies.hide() self.model_th = self.therm.getThermalScalarModel() if self.model_th != 'off' and self.comp.getCompressibleModel() == 'off': self.groupBoxThermal.show() self.modelThermal = ComboModel(self.comboBoxThermal,1,1) self.thermal = self.therm.getThermalScalarName() self.modelThermal.addItem(self.tr(self.thermal),self.thermal) self.modelThermal.setItem(str_model = self.thermal) else: self.groupBoxThermal.hide() self.meteo_list = "" self.meteo_list = self.sca_mo.getMeteoScalarsNameList() self.groupBoxMeteo.hide() if (self.atm.getAtmosphericFlowsModel() != "off" and self.nature == 'wall'): self.groupBoxThermal.hide() if (self.atm.getAtmosphericFlowsModel() != "off" and \ (self.nature == 'inlet' or self.nature == 'outlet')): label = self.__boundary.getLabel() nature = "meteo_" + self.nature bb = Boundary(nature, label, self.__case) if bb.getMeteoDataStatus() == 'off': self.groupBoxMeteo.hide() self.groupBoxThermal.show() self.modelMeteo = ComboModel(self.comboBoxMeteo, 1, 1) if len(self.meteo_list) > 0: self.groupBoxMeteo.show() for m in self.meteo_list: self.modelMeteo.addItem(self.tr(m), m) self.meteo = self.meteo_list[0] self.modelMeteo.setItem(str_model = self.meteo) else: self.groupBoxMeteo.hide() self.groupBoxThermal.hide() self.initializeVariables() def initializeVariables(self): """ Initialize widget """ # Initalize exchange coef self.lineEditExThermal.hide() self.labelExThermal.hide() self.lineEditExSpecies.hide() self.labelExSpecies.hide() self.lineEditExMeteo.hide() self.labelExMeteo.hide() # Initalize thermal self.lineEditValueThermal.hide() self.labelValueThermal.hide() self.pushButtonThermal.setEnabled(False) setGreenColor(self.pushButtonThermal, False) if self.model_th != 'off' and self.comp.getCompressibleModel() == 'off': self.thermal_type = self.__boundary.getScalarChoice(self.thermal) self.modelTypeThermal.setItem(str_model = self.thermal_type) self.labelValueThermal.setText('Value') self.groupBoxThermal.setTitle('Thermal') if self.thermal_type in ('dirichlet', 'exchange_coefficient', 'neumann'): self.labelValueThermal.show() self.lineEditValueThermal.show() if self.thermal_type == 'exchange_coefficient': self.lineEditExThermal.show() self.labelExThermal.show() v = self.__boundary.getScalarValue(self.thermal, 'dirichlet') w = self.__boundary.getScalarValue(self.thermal, 'exchange_coefficient') self.lineEditValueThermal.setText(str(v)) self.lineEditExThermal.setText(str(w)) else: v = self.__boundary.getScalarValue(self.thermal, self.thermal_type) self.lineEditValueThermal.setText(str(v)) if self.thermal_type == 'neumann': self.labelValueThermal.setText('Flux') if self.nature == 'outlet': self.groupBoxThermal.setTitle('Thermal for backflow') elif self.thermal_type in ('exchange_coefficient_formula', 'dirichlet_formula', 'neumann_formula'): self.pushButtonThermal.setEnabled(True) setGreenColor(self.pushButtonThermal, True) # Initalize species self.labelValueSpecies.hide() self.lineEditValueSpecies.hide() self.pushButtonSpecies.setEnabled(False) setGreenColor(self.pushButtonSpecies, False) if self.species_list != None and self.species_list != []: self.species_type = self.__boundary.getScalarChoice(self.species) self.modelTypeSpecies.setItem(str_model = self.species_type) self.labelValueSpecies.setText('Value') self.groupBoxSpecies.setTitle('Species') if self.species_type in ('dirichlet', 'exchange_coefficient', 'neumann'): self.labelValueSpecies.show() self.lineEditValueSpecies.show() if self.species_type == 'exchange_coefficient': self.lineEditExSpecies.show() self.labelExSpecies.show() v = self.__boundary.getScalarValue(self.species, 'dirichlet') w = self.__boundary.getScalarValue(self.species, 'exchange_coefficient') self.lineEditValueSpecies.setText(str(v)) self.lineEditExSpecies.setText(str(w)) else: v = self.__boundary.getScalarValue(self.species, self.species_type) self.lineEditValueSpecies.setText(str(v)) if self.species_type == 'neumann': self.labelValueSpecies.setText('Flux') if self.nature == 'outlet': self.groupBoxSpecies.setTitle('Species for backflow') elif self.species_type in ('exchange_coefficient_formula', 'dirichlet_formula', 'neumann_formula'): self.pushButtonSpecies.setEnabled(True) setGreenColor(self.pushButtonSpecies, True) # Initalize meteo self.labelValueMeteo.hide() self.lineEditValueMeteo.hide() self.pushButtonMeteo.setEnabled(False) setGreenColor(self.pushButtonMeteo, False) if (self.meteo_list and (self.nature == 'inlet' or self.nature == 'outlet')): label = self.__boundary.getLabel() nature = "meteo_" + self.nature bb = Boundary(nature, label, self.__case) if bb.getMeteoDataStatus() == 'off': self.meteo_type = self.__boundary.getScalarChoice(self.meteo) self.modelTypeMeteo.setItem(str_model = self.meteo_type) self.labelValueMeteo.setText('Value') self.groupBoxMeteo.setTitle('Meteo') if self.meteo_type in ('dirichlet', 'exchange_coefficient', 'neumann'): self.labelValueMeteo.show() self.lineEditValueMeteo.show() if self.meteo_type == 'exchange_coefficient': self.lineEditExMeteo.show() self.labelExMeteo.show() v = self.__boundary.getScalarValue(self.meteo, 'dirichlet') w = self.__boundary.getScalarValue(self.meteo, 'exchange_coefficient') self.lineEditValueMeteo.setText(str(v)) self.lineEditExMeteo.setText(str(w)) else: v = self.__boundary.getScalarValue(self.meteo, self.meteo_type) self.lineEditValueMeteo.setText(str(v)) if self.meteo_type == 'neumann': self.labelValueMeteo.setText('Flux') if self.nature == 'outlet': self.groupBoxMeteo.setTitle('Meteo for backflow') if self.meteo_type in ('exchange_coefficient_formula', 'dirichlet_formula', 'neumann_formula'): self.pushButtonMeteo.setEnabled(True) setGreenColor(self.pushButtonMeteo, True) def showWidget(self, boundary): """ Show the widget """ if DefineUserScalarsModel(self.__case).getScalarNameList() or\ DefineUserScalarsModel(self.__case).getMeteoScalarsNameList() or\ DefineUserScalarsModel(self.__case).getThermalScalarName(): self.__setBoundary(boundary) self.show() else: self.hideWidget() def hideWidget(self): """ Hide all """ self.hide() @pyqtSignature("const QString&") def slotThermalChoice(self, text): """ INPUT label for choice of zone """ self.thermal = self.modelThermal.dicoV2M[str(text)] self.initializeVariables() @pyqtSignature("const QString&") def slotThermalTypeChoice(self, text): """ INPUT label for choice of zone """ self.thermal_type = self.modelTypeThermal.dicoV2M[str(text)] self.__boundary.setScalarChoice(self.thermal, self.thermal_type) self.initializeVariables() @pyqtSignature("const QString&") def slotSpeciesChoice(self, text): """ INPUT label for choice of zone """ self.species = self.modelSpecies.dicoV2M[str(text)] self.initializeVariables() @pyqtSignature("const QString&") def slotSpeciesTypeChoice(self, text): """ INPUT label for choice of zone """ self.species_type = self.modelTypeSpecies.dicoV2M[str(text)] self.__boundary.setScalarChoice(self.species, self.species_type) self.initializeVariables() @pyqtSignature("const QString&") def slotMeteoChoice(self, text): """ INPUT label for choice of zone """ self.meteo = self.modelMeteo.dicoV2M[str(text)] self.initializeVariables() @pyqtSignature("const QString&") def slotMeteoTypeChoice(self, text): """ INPUT label for choice of zone """ self.meteo_type= self.modelTypeMeteo.dicoV2M[str(text)] self.__boundary.setScalarChoice(self.meteo, self.meteo_type) self.initializeVariables() @pyqtSignature("") def slotThermalFormula(self): """ """ name = self.thermal exp = self.__boundary.getScalarFormula(self.thermal, self.thermal_type) exa = """#example: """ if self.thermal_type == 'dirichlet_formula': req = [(name, str(name))] elif self.thermal_type == 'neumann_formula': req = [("flux", "flux")] elif self.thermal_type == 'exchange_coefficient_formula': req = [(name, str(nameal)),("hc", "heat coefficient")] sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] 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("slotThermalFormula -> %s" % str(result)) self.__boundary.setScalarFormula(self.thermal, self.thermal_type, result) setGreenColor(self.pushButtonThermal, False) @pyqtSignature("") def slotSpeciesFormula(self): """ """ exp = self.__boundary.getScalarFormula(self.species, self.species_type) exa = """#example: """ if self.species_type == 'dirichlet_formula': req = [(self.species, str(self.species))] elif self.species_type == 'neumann_formula': req = [("flux", "flux")] elif self.species_type == 'exchange_coefficient_formula': req = [(self.species, str(self.species)),("hc", "heat coefficient")] sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] 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("slotSpeciesFormula -> %s" % str(result)) self.__boundary.setScalarFormula(self.species, self.species_type, result) setGreenColor(self.pushButtonSpecies, False) @pyqtSignature("") def slotMeteoFormula(self): """ """ exp = self.__boundary.getScalarFormula(self.meteo, self.meteo_type) exa = """#example: """ if self.meteo_type == 'dirichlet_formula': req = [(self.meteo, str(self.meteo))] elif self.meteo_type == 'neumann_formula': req = [("flux", "flux")] elif self.meteo_type == 'exchange_coefficient_formula': req = [(self.meteo, str(self.meteo)), ("hc", "heat coefficient")] sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] 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("slotMeteoFormula -> %s" % str(result)) self.__boundary.setScalarFormula(self.meteo, self.meteo_type, result) setGreenColor(self.pushButtonMeteo, False) @pyqtSignature("const QString&") def slotValueThermal(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) if self.thermal_type in ('dirichlet', 'neumann'): self.__boundary.setScalarValue(self.thermal, self.thermal_type, value) elif self.thermal_type == 'exchange_coefficient': self.__boundary.setScalarValue(self.thermal, 'dirichlet', value) @pyqtSignature("const QString&") def slotValueSpecies(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) if self.species_type in ('dirichlet', 'neumann'): self.__boundary.setScalarValue(self.species, self.species_type, value) elif self.species_type == 'exchange_coefficient' : self.__boundary.setScalarValue(self.species, 'dirichlet', value) @pyqtSignature("const QString&") def slotValueMeteo(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) if self.meteo_type in ('dirichlet', 'neumann'): self.__boundary.setScalarValue(self.meteo, self.meteo_type, value) elif self.meteo_type == 'exchange_coefficient': self.__boundary.setScalarValue(self.meteo, 'dirichlet', value) @pyqtSignature("const QString&") def slotExThermal(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__boundary.setScalarValue(self.thermal, 'exchange_coefficient', value) @pyqtSignature("const QString&") def slotExSpecies(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__boundary.setScalarValue(self.species, 'exchange_coefficient', value) @pyqtSignature("const QString&") def slotExMeteo(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__boundary.setScalarValue(self.meteo, 'exchange_coefficient', value) def tr(self, text): """ Translation """ return text
class BatchRunningView(QWidget, Ui_BatchRunningForm): """ This class is devoted to the Computer selection. When a new computer is selected, The old data frame is deleted and a new apropriate frame is open. If the batch script file name is known, informations are display in the apropiate widget. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_BatchRunningForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.mdl = ScriptRunningModel(self.case) # Check if the script file name is already defined if self.case['scripts_path']: if not self.case['runcase']: if self.case['package'].runcase in os.listdir(self.case['scripts_path']): runcase_path = os.path.join(self.case['scripts_path'], self.case['package'].runcase) self.case['runcase'] = cs_runcase.runcase(runcase_path, package=self.case['package']) # Get batch type config = configparser.ConfigParser() config.read(self.case['package'].get_configfiles()) cs_batch_type = None if config.has_option('install', 'batch'): cs_batch_type = config.get('install', 'batch') if os.path.isabs(cs_batch_type): i = cs_batch_type.rfind(".") if i > -1: cs_batch_type = cs_batch_type[i+1:] self.case['batch_type'] = cs_batch_type # Get MPI and OpenMP features self.have_mpi = False self.have_openmp = False config_features = self.case['package'].config.features if config.has_option('install', 'compute_versions'): compute_versions = config.get('install', 'compute_versions').split(':') if compute_versions[0]: pkg_compute = self.case['package'].get_alternate_version(compute_versions[0]) config_features = pkg_compute.config.features if config_features['mpi'] == 'yes': self.have_mpi = True if config_features['openmp'] == 'yes': self.have_openmp = True self.jmdl = BatchRunningModel(parent, self.case) # Batch info self.hideBatchInfo() self.labelNProcs.hide() self.spinBoxNProcs.hide() self.labelNThreads.hide() self.spinBoxNThreads.hide() self.class_list = None if self.case['batch_type'] != None: self.groupBoxArchi.setTitle("Job and script files") self.labelBatch.show() self.toolButtonSearchBatch.show() validatorSimpleName = RegExpValidator(self.lineEditJobName, QRegExp("[_A-Za-z0-9]*")) validatorAccountName = RegExpValidator(self.lineEditJobAccount, QRegExp("\\S+")) self.lineEditJobName.setValidator(validatorSimpleName) self.lineEditJobAccount.setValidator(validatorAccountName) self.lineEditJobWCKey.setValidator(validatorAccountName) self.pushButtonRunSubmit.setText("Submit job") else: if self.jmdl.dictValues['run_nprocs'] == None: try: # For backwards compatibility # (this is a specific case, as we move information from # the XML model to the batch script) self.jmdl.dictValues['run_nprocs'] = self.mdl.getString('n_procs') self.mdl.setString('n_procs', None) except Exception: pass # Connections if self.case['batch_type'] != None: self.connect(self.lineEditJobName, SIGNAL("textChanged(const QString &)"), self.slotJobName) self.connect(self.spinBoxNodes, SIGNAL("valueChanged(int)"), self.slotJobNodes) self.connect(self.spinBoxPpn, SIGNAL("valueChanged(int)"), self.slotJobPpn) self.connect(self.spinBoxProcs, SIGNAL("valueChanged(int)"), self.slotJobProcs) self.connect(self.spinBoxThreads, SIGNAL("valueChanged(int)"), self.slotJobThreads) self.connect(self.spinBoxDays, SIGNAL("valueChanged(int)"), self.slotJobWallTime) self.connect(self.spinBoxHours, SIGNAL("valueChanged(int)"), self.slotJobWallTime) self.connect(self.spinBoxMinutes, SIGNAL("valueChanged(int)"), self.slotJobWallTime) self.connect(self.spinBoxSeconds, SIGNAL("valueChanged(int)"), self.slotJobWallTime) self.connect(self.comboBoxClass, SIGNAL("activated(const QString&)"), self.slotClass) self.connect(self.lineEditJobAccount, SIGNAL("textChanged(const QString &)"), self.slotJobAccount) self.connect(self.lineEditJobWCKey, SIGNAL("textChanged(const QString &)"), self.slotJobWCKey) else: self.connect(self.spinBoxNProcs, SIGNAL("valueChanged(int)"), self.slotNProcs) self.connect(self.spinBoxNThreads, SIGNAL("valueChanged(int)"), self.slotNThreads) self.connect(self.toolButtonSearchBatch, SIGNAL("clicked()"), self.slotSearchBatchFile) self.connect(self.comboBoxRunType, SIGNAL("activated(const QString&)"), self.slotArgRunType) self.connect(self.toolButtonAdvanced, SIGNAL("clicked()"), self.slotAdvancedOptions) self.connect(self.pushButtonRunSubmit, SIGNAL("clicked()"), self.slotBatchRunning) # Combomodels self.modelArg_cs_verif = ComboModel(self.comboBoxRunType, 2, 1) self.modelArg_cs_verif.addItem(self.tr("Import mesh only"), 'none') self.modelArg_cs_verif.addItem(self.tr("Mesh preprocessing"), 'mesh preprocess') self.modelArg_cs_verif.addItem(self.tr("Mesh quality criteria"), 'mesh quality') self.modelArg_cs_verif.addItem(self.tr("Standard"), 'standard') self.modelArg_cs_verif.setItem(str_model=self.mdl.getRunType()) # initialize Widgets # Check if the script file name is already defined if self.case['runcase']: name = os.path.basename(self.case['runcase'].path) self.labelBatchName.setText(str(name)) setGreenColor(self.toolButtonSearchBatch, False) else: setGreenColor(self.toolButtonSearchBatch, True) if self.case['batch_type'] != None and self.case['runcase']: self.displayBatchInfo() # Script info is based on the XML model self.displayScriptInfo() self.case.undoStartGlobal() @pyqtSignature("const QString &") def slotJobName(self, v): """ Increment, decrement and colorize the input argument entry """ if self.lineEditJobName.validator().state == QValidator.Acceptable: self.jmdl.dictValues['job_name'] = str(v) self.jmdl.updateBatchFile('job_name') @pyqtSignature("int") def slotJobNodes(self, v): """ Increment, decrement and colorize the input argument entry """ self.jmdl.dictValues['job_nodes'] = str(self.spinBoxNodes.text()) self.jmdl.updateBatchFile('job_nodes') @pyqtSignature("int") def slotJobPpn(self, v): """ Increment, decrement and colorize the input argument entry """ self.jmdl.dictValues['job_ppn'] = str(self.spinBoxPpn.text()) self.jmdl.updateBatchFile('job_ppn') @pyqtSignature("int") def slotJobProcs(self, v): """ Increment, decrement and colorize the input argument entry """ self.jmdl.dictValues['job_procs'] = str(self.spinBoxProcs.text()) self.jmdl.updateBatchFile('job_procs') @pyqtSignature("int") def slotJobThreads(self, v): """ Increment, decrement and colorize the input argument entry """ self.jmdl.dictValues['job_threads'] = str(self.spinBoxThreads.text()) self.jmdl.updateBatchFile('job_threads') @pyqtSignature("") def slotJobWallTime(self): h_cput = self.spinBoxDays.value()*24 + self.spinBoxHours.value() m_cput = self.spinBoxMinutes.value() s_cput = self.spinBoxSeconds.value() self.jmdl.dictValues['job_walltime'] = h_cput*3600 + m_cput*60 + s_cput self.jmdl.updateBatchFile('job_walltime') @pyqtSignature("") def slotClass(self): self.jmdl.dictValues['job_class'] = str(self.comboBoxClass.currentText()) if len(self.jmdl.dictValues['job_class']) > 0: self.jmdl.updateBatchFile('job_class') @pyqtSignature("const QString &") def slotJobAccount(self, v): """ Increment, decrement and colorize the input argument entry """ if self.lineEditJobAccount.validator().state == QValidator.Acceptable: self.jmdl.dictValues['job_account'] = str(v) self.jmdl.updateBatchFile('job_account') @pyqtSignature("const QString &") def slotJobWCKey(self, v): """ Increment, decrement and colorize the input argument entry """ if self.lineEditJobWCKey.validator().state == QValidator.Acceptable: self.jmdl.dictValues['job_wckey'] = str(v) self.jmdl.updateBatchFile('job_wckey') @pyqtSignature("const QString &") def slotArgRunType(self, text): """ Input run type option. """ self.run_type = self.modelArg_cs_verif.dicoV2M[str(text)] self.mdl.setRunType(self.run_type) @pyqtSignature("int") def slotNProcs(self, v): """ Increment, decrement and colorize the input argument entry """ if v > 1: self.jmdl.dictValues['run_nprocs'] = str(v) else: self.jmdl.dictValues['run_nprocs'] = None self.jmdl.updateBatchFile('run_nprocs') @pyqtSignature("int") def slotNThreads(self, v): """ Increment, decrement and colorize the input argument entry """ if v > 1: self.jmdl.dictValues['run_nthreads'] = str(v) else: self.jmdl.dictValues['run_nthreads'] = None self.jmdl.updateBatchFile('run_nthreads') @pyqtSignature("") def slotAdvancedOptions(self): """ Ask one popup for advanced specifications """ log.debug("slotAdvancedOptions") dialog = BatchRunningAdvancedOptionsDialogView(self) if dialog.exec_(): log.debug("slotAdvancedOptions validated") @pyqtSignature("") def slotBatchRunning(self): """ Launch Code_Saturne batch running. """ # Is the file saved? if self.case['new'] == "yes" or len(self.case['undo']) > 0 or len(self.case['redo']) > 0: title = self.tr("Warning") msg = self.tr("The current case must be saved before "\ "running the ") + self.tr(self.case['package']).code_name + self.tr(" script.") QMessageBox.information(self, title, msg) return # Ensure code is run from a case subdirectory prv_dir = os.getcwd() os.chdir(self.case['scripts_path']) # Do we have a mesh ? have_mesh = False node_ecs = self.case.xmlGetNode('solution_domain') if node_ecs.xmlGetNode('meshes_list'): if node_ecs.xmlGetNode('meshes_list').xmlGetNodeList('mesh'): have_mesh = True if node_ecs.xmlGetNode('mesh_input', 'path'): have_mesh = True if not have_mesh: title = self.tr("Warning") msg = self.tr("You have to select a mesh.\n\n") QMessageBox.information(self, title, msg) return # Verify if boundary condition definitions exist bd = LocalizationModel('BoundaryZone', self.case) if not bd.getZones(): if self.case['no_boundary_conditions'] == False: title = self.tr("Warning") msg = self.tr("No boundary definition declared.\n\n") QMessageBox.warning(self, title, msg) self.case['no_boundary_conditions'] = True # Build command line key = self.case['batch_type'] batch = cs_exec_environment.enquote_arg(self.case['runcase'].path) if key == None: run_id, run_title = self.__suggest_run_id() self.__updateRuncase(run_id) cmd = batch key = 'localhost' elif key[0:3] == 'CCC': cmd = 'msub ' + batch elif key[0:5] == 'LOADL': cmd = 'llsubmit ' + batch elif key[0:3] == 'LSF': cmd = 'bsub < ' + batch elif key[0:3] == 'PBS' or key[0:3] == 'SGE': cmd = 'qsub ' + batch elif key[0:5] == 'SLURM': cmd = 'sbatch ' + batch else: pass if self.case['salome'] or key == 'localhost': dlg = ListingDialogView(self.parent, self.case, run_title, cmd) dlg.show() else: cs_exec_environment.run_command(cmd) if self.case['salome'] or key == 'localhost': self.__updateRuncase('') # remove --id <id> from runcase os.chdir(prv_dir) def __suggest_run_id(self): """ Return an id. """ cmd = os.path.join(self.case['package'].get_dir('bindir'), self.case['package'].name) cmd = cs_exec_environment.enquote_arg(cmd) + " run --suggest-id" r_title = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read()[:-1] r_id = os.path.join(self.case['resu_path'], r_title) run_id = r_id run_title = r_title j = 1 while os.path.isdir(run_id): j += 1 run_id = r_id + "_" + str(j) run_title = r_title + "(" + str(j) + ")" return os.path.basename(run_id), run_title def __updateRuncase(self, run_id): """ Update the command line in the launcher C{runcase}. """ runcase = self.case['runcase'] runcase.set_run_id(run_id=run_id) runcase.save() def getCommandOutput(self, cmd): """ Run a command and return it's standard output. """ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) lines = [] while True: l = p.stdout.readline() lines.append(l.strip()) if len(l) == 0 and p.poll() != None: break output = p.communicate() if p.returncode == 0: return lines def getClassList(self): """ Layout of the second part of this page. """ self.class_list = [] try: if self.case['batch_type'][0:3] == 'CCC': output = self.getCommandOutput('class') for l in output[1:]: if len(l) == 0: break else: self.class_list.append(l.split(' ')[0]) elif self.case['batch_type'][0:5] == 'LOADL': output = self.getCommandOutput('llclass') ignore = True for l in output: if l[0:3] == '---': ignore = not ignore elif ignore == False: self.class_list.append(l.split(' ')[0]) elif self.case['batch_type'][0:3] == 'LSF': output = self.getCommandOutput('bqueues') ignore = True for l in output[1:]: if len(l) == 0: break else: self.class_list.append(l.split(' ')[0]) elif self.case['batch_type'][0:3] == 'PBS': output = self.getCommandOutput('qstat -q') ignore = True for l in output: if l[0:3] == '---': ignore = not ignore elif ignore == False: self.class_list.append(l.split(' ')[0]) elif self.case['batch_type'][0:3] == 'SGE': output = self.getCommandOutput('qconf -sc') for l in output: if l[0:1] != '#': self.class_list.append(l.split(' ')[0]) elif self.case['batch_type'][0:5] == 'SLURM': output = self.getCommandOutput('sinfo -s') for l in output[1:]: if len(l) == 0: break else: name = l.split(' ')[0] if name[-1:] == '*': name = name[:-1] self.class_list.append(name) except Exception: pass def hideBatchInfo(self): """ hide all batch info before displaying a selected subset """ self.groupBoxJob.hide() self.labelJobName.hide() self.lineEditJobName.hide() self.labelNodes.hide() self.spinBoxNodes.hide() self.labelPpn.hide() self.spinBoxPpn.hide() self.labelProcs.hide() self.spinBoxProcs.hide() self.labelThreads.hide() self.spinBoxThreads.hide() self.labelClass.hide() self.labelWTime.hide() self.spinBoxDays.hide() self.labelDays.hide() self.spinBoxHours.hide() self.labelHours.hide() self.spinBoxMinutes.hide() self.labelMinutes.hide() self.spinBoxSeconds.hide() self.labelSeconds.hide() self.comboBoxClass.hide() self.labelJobAccount.hide() self.lineEditJobAccount.hide() self.labelJobWCKey.hide() self.lineEditJobWCKey.hide() def displayBatchInfo(self): """ Layout of the second part of this page. """ self.job_name = self.jmdl.dictValues['job_name'] self.job_nodes = self.jmdl.dictValues['job_nodes'] self.job_ppn = self.jmdl.dictValues['job_ppn'] self.job_procs = self.jmdl.dictValues['job_procs'] self.job_threads = self.jmdl.dictValues['job_threads'] self.job_walltime = self.jmdl.dictValues['job_walltime'] self.job_class = self.jmdl.dictValues['job_class'] self.job_account = self.jmdl.dictValues['job_account'] self.job_wckey = self.jmdl.dictValues['job_wckey'] if self.job_name != None: self.labelJobName.show() self.lineEditJobName.setText(str(self.job_name)) self.lineEditJobName.show() if self.job_nodes != None: self.labelNodes.show() self.spinBoxNodes.setValue(int(self.job_nodes)) self.spinBoxNodes.show() if self.job_ppn != None: self.labelPpn.show() self.spinBoxPpn.setValue(int(self.job_ppn)) self.spinBoxPpn.show() if self.job_procs != None: self.labelProcs.show() self.spinBoxProcs.setValue(int(self.job_procs)) self.spinBoxProcs.show() if self.job_threads != None: self.labelThreads.show() self.spinBoxThreads.setValue(int(self.job_threads)) self.spinBoxThreads.show() if self.job_walltime != None: seconds = self.job_walltime minutes = seconds / 60 hours = minutes / 60 days = hours / 24 seconds = seconds % 60 minutes = minutes % 60 hours = hours % 24 self.spinBoxDays.setValue(days) self.spinBoxHours.setValue(hours) self.spinBoxMinutes.setValue(minutes) self.spinBoxSeconds.setValue(seconds) self.labelWTime.show() self.spinBoxDays.show() self.labelDays.show() self.spinBoxHours.show() self.labelHours.show() self.spinBoxMinutes.show() self.labelMinutes.show() self.spinBoxSeconds.show() self.labelSeconds.show() if self.job_class != None: # Only one pass here if self.class_list == None: self.getClassList() if len(self.class_list) > 0: for c in self.class_list: self.comboBoxClass.addItem(self.tr(c), to_qvariant(c)) else: c = self.job_class self.comboBoxClass.addItem(self.tr(c), to_qvariant(c)) # All passes try: index = self.class_list.index(self.job_class) self.comboBoxClass.setCurrentIndex(index) except Exception: if len(self.class_list) > 0: self.job_class = self.class_list[0] self.labelClass.show() self.comboBoxClass.show() # update runcase (compute class specific to ivanoe) self.jmdl.dictValues['job_class'] = str(self.comboBoxClass.currentText()) if len(self.jmdl.dictValues['job_class']) > 0: self.jmdl.updateBatchFile('job_class') if self.job_account != None: self.labelJobAccount.show() self.lineEditJobAccount.setText(str(self.job_account)) self.lineEditJobAccount.show() if self.job_wckey != None: self.labelJobWCKey.show() self.lineEditJobWCKey.setText(str(self.job_wckey)) self.lineEditJobWCKey.show() # Show Job management box if self.case['batch_type'][0:5] == 'LOADL': self.groupBoxJob.setTitle("Load Leveler job parameters") self.labelJobAccount.setText(str("Group")) self.lineEditJobAccount.setToolTip("To obtain a list of defined groups, run <b><tt>xloadl</tt></b>, then select <i>File -> Build a Job</i>, and check the group names in the <i>Group</i> field") elif self.case['batch_type'][0:3] == 'LSF': self.groupBoxJob.setTitle("LSF job parameters") elif self.case['batch_type'][0:3] == 'PBS': self.groupBoxJob.setTitle("PBS job parameters") elif self.case['batch_type'][0:3] == 'SGE': self.groupBoxJob.setTitle("Sun Grid Engine job parameters") if self.case['batch_type'][0:5] == 'SLURM': self.groupBoxJob.setTitle("SLURM job parameters") else: self.groupBoxJob.setTitle("Batch job parameters") self.groupBoxJob.show() # Update file self.jmdl.updateBatchFile() def displayScriptInfo(self): """ Layout of the second part of this page. """ if self.case['batch_type'] == None: if self.have_mpi: self.labelNProcs.show() self.spinBoxNProcs.show() if self.have_openmp: self.labelNThreads.show() self.spinBoxNThreads.show() else: self.labelNProcs.hide() self.spinBoxNProcs.hide() self.labelNThreads.hide() self.spinBoxNThreads.hide() if self.case['batch_type'] == None: if self.have_mpi: n_procs_s = self.jmdl.dictValues['run_nprocs'] if n_procs_s: n_procs = int(n_procs_s) else: n_procs = 1 self.spinBoxNProcs.setValue(n_procs) if self.have_openmp == 'yes': n_threads_s = self.jmdl.dictValues['run_nthreads'] if n_threads_s: n_threads = int(n_threads_s) else: n_threads = 1 self.spinBoxNThreads.setValue(n_threads) else: pass @pyqtSignature("") def slotSearchBatchFile(self): """ Open a FileDialog in order to search the batch command file in the system file. """ file_name = "" if self.case['scripts_path'] and os.path.isdir(self.case['scripts_path']): path = self.case['scripts_path'] else: path = os.getcwd() title = self.tr("Select the batch script") filetypes = self.tr("All Files (*)") file_name = QFileDialog.getOpenFileName(self, title, path, filetypes) file_name = str(file_name) if file_name: launcher = os.path.basename(file_name) setGreenColor(self.toolButtonSearchBatch, False) if self.case['scripts_path'] == os.path.dirname(file_name): self.case['runcase'] = cs_runcase.runcase(os.path.join(self.case['scripts_path'], launcher), package=self.case['package']) self.labelBatchName.setText(str(launcher)) self.hideBatchInfo() if self.case['batch_type'] != None: self.displayBatchInfo() else: title = self.tr("Warning") msg = self.tr("The new batch file is not in scripts "\ "directory given in the 'Identity and paths' "\ "section.\n\n" + \ "Verify the existence and location of these files, "\ "and the 'Identity and Pathes' section") QMessageBox.warning(self, title, msg) def tr(self, text): """ Translation """ return text
class BoundaryConditionsMobileMeshView(QWidget, Ui_BoundaryConditionsMobileMeshForm): """ Boundary condifition for mobil mesh (ALE and/or Fluid-interaction) """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsMobileMeshForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.__model = MobileMeshModel(self.__case) self.__comboModel = ComboModel(self.comboMobilBoundary, 6, 1) self.__comboModel.addItem(self.tr("Fixed boundary"), "fixed_boundary") self.__comboModel.addItem(self.tr("Sliding boundary"), "sliding_boundary") self.__comboModel.addItem(self.tr("Internal coupling"), "internal_coupling") self.__comboModel.addItem(self.tr("External coupling"), "external_coupling") self.__comboModel.addItem(self.tr("Fixed velocity"), "fixed_velocity") self.__comboModel.addItem(self.tr("Fixed displacement"), "fixed_displacement") self.connect(self.comboMobilBoundary, SIGNAL("activated(const QString&)"), self.__slotCombo) self.connect(self.pushButtonMobilBoundary, SIGNAL("clicked(bool)"), self.__slotFormula) self.__case.undoStartGlobal() @pyqtSignature("const QString&") def __slotFormula(self, text): """ Run formula editor. """ exp = self.__boundary.getFormula() aleChoice = self.__boundary.getALEChoice(); if aleChoice == "fixed_velocity": if not exp: exp = 'mesh_velocity_U =' req = [('mesh_velocity_U', 'Fixed velocity of the mesh'), ('mesh_velocity_V', 'Fixed velocity of the mesh'), ('mesh_velocity_W', 'Fixed velocity of the mesh')] exa = 'mesh_velocity_U = 1000;\nmesh_velocity_V = 1000;\nmesh_velocity_W = 1000;' elif aleChoice == "fixed_displacement": if not exp: exp = 'mesh_x =' req = [('mesh_x', 'Fixed displacement of the mesh'), ('mesh_y', 'Fixed displacement of the mesh'), ('mesh_z', 'Fixed displacement of the mesh')] exa = 'mesh_x = 1000;\nmesh_y = 1000;\nmesh_z = 1000;' symbs = [('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] dialog = QMeiEditorView(self, check_syntax = self.__case['package'].get_check_syntax(), expression = exp, required = req, symbols = symbs, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMobileMeshBoundary -> %s" % str(result)) self.__boundary.setFormula(result) setGreenColor(self.pushButtonMobilBoundary, False) @pyqtSignature("const QString&") def __slotCombo(self, text): """ Called when the combobox changed. """ modelData = self.__comboModel.dicoV2M[str(text)] # Enable/disable formula button. isFormulaEnabled = modelData in ["fixed_velocity", "fixed_displacement"] self.pushButtonMobilBoundary.setEnabled(isFormulaEnabled) setGreenColor(self.pushButtonMobilBoundary, isFormulaEnabled) self.__boundary.setALEChoice(modelData) def showWidget(self, b): """ Show the widget """ if self.__model.getMethod() != "off": self.__boundary = Boundary("mobile_boundary", b.getLabel(), self.__case) modelData = self.__boundary.getALEChoice() self.__comboModel.setItem(str_model=modelData) isFormulaEnabled = modelData in ["fixed_velocity", "fixed_displacement"] self.pushButtonMobilBoundary.setEnabled(isFormulaEnabled) self.show() else: self.hideWidget() def hideWidget(self): """ Hide all """ self.hide() 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 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 BatchRunningAdvancedOptionsDialogView(QDialog, Ui_BatchRunningAdvancedOptionsDialogForm): """ Advanced dialog """ def __init__(self, parent): """ Constructor """ QDialog.__init__(self, parent) Ui_BatchRunningAdvancedOptionsDialogForm.__init__(self) self.setupUi(self) self.setWindowTitle(self.tr("Advanced options")) self.parent = parent # Combo models self.modelCSOUT1 = ComboModel(self.comboBox_6, 2, 1) self.modelCSOUT2 = ComboModel(self.comboBox_7, 3, 1) # Combo items self.modelCSOUT1.addItem(self.tr("to standard output"), 'stdout') self.modelCSOUT1.addItem(self.tr("to listing"), 'listing') self.modelCSOUT2.addItem(self.tr("no output"), 'null') self.modelCSOUT2.addItem(self.tr("to standard output"), 'stdout') self.modelCSOUT2.addItem(self.tr("to listing_n<p>"), 'listing') # Connections self.connect(self.toolButton_2, SIGNAL("clicked()"), self.slotSearchFile) self.connect(self.lineEdit_3, SIGNAL("textChanged(const QString &)"), self.slotValgrind) self.connect(self.comboBox_6, SIGNAL("activated(const QString&)"), self.slotLogType) self.connect(self.comboBox_7, SIGNAL("activated(const QString&)"), self.slotLogType) # Previous values self.valgrind = self.parent.mdl.getString('valgrind') if self.valgrind is not None: self.lineEdit_3.setText(str(self.valgrind)) self.setLogType() @pyqtSignature("const QString &") def slotValgrind(self, text): """ Input for Valgrind. """ self.valgrind = str(text) def setLogType(self): """ Set logging arguments. """ self.log_type = self.parent.mdl.getLogType() self.modelCSOUT1.setItem(str_model=self.log_type[0]) self.modelCSOUT2.setItem(str_model=self.log_type[1]) @pyqtSignature("const QString &") def slotLogType(self, text): """ Input logging options. """ self.log_type = [self.modelCSOUT1.dicoV2M[str(self.comboBox_6.currentText())], self.modelCSOUT2.dicoV2M[str(self.comboBox_7.currentText())]] @pyqtSignature("") def slotSearchFile(self): """ Choice temporary directory for batch """ file_name = "" title = self.tr("Select file for use VALGRIND option") path = os.getcwd() filetypes = self.tr("All Files (*)") file_name = QFileDialog.getOpenFileName(self, title, path, filetypes) file_name = str(file_name) # TO CHECK ... if file_name: self.valgrind = str(self.lineEdit_3.text()) if not self.valgrind: new = file_name + " --tool=memcheck" else: new = "" for i in self.valgrind.split(): if i == self.valgrind.split()[0]: i = file_name new = new + i + ' ' self.valgrind = new self.lineEdit_3.setText(str(self.valgrind)) def get_result(self): """ Method to get the result """ return self.result def accept(self): """ Method called when user clicks 'OK' """ self.parent.mdl.setString('valgrind', self.valgrind.strip()) self.parent.mdl.setLogType(self.log_type) QDialog.accept(self) def reject(self): """ Method called when user clicks 'Cancel' """ QDialog.reject(self) 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 InitializationView(QWidget, Ui_InitializationForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_InitializationForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.init = InitializationModel(self.case) self.turb = TurbulenceModel(self.case) self.therm = ThermalScalarModel(self.case) self.th_sca = DefineUserScalarsModel(self.case) self.comp = CompressibleModel(self.case) self.volzone = LocalizationModel('VolumicZone', self.case) # create group to control hide/show options self.turb_group = [self.labelTurbulence, self.pushButtonTurbulence, self.comboBoxTurbulence] self.thermal_group = [self.labelThermal, self.pushButtonThermal] self.species_group = [self.labelSpecies, self.comboBoxSpecies, self.pushButtonSpecies] self.meteo_group = [self.labelMeteo, self.comboBoxMeteo, self.pushButtonMeteo] self.thermodynamic_list = ['Pressure', 'Density', 'Temperature', 'Energy'] # 1/ Combo box models self.modelZone = ComboModel(self.comboBoxZone, 1, 1) if self.comp.getCompressibleModel() != 'off': self.groupBoxThermodynamic.show() else: self.groupBoxThermodynamic.hide() self.zone = "" zones = self.volzone.getZones() for zone in zones: if zone.getNature()['initialization'] == "on": label = zone.getLabel() name = str(zone.getCodeNumber()) self.modelZone.addItem(self.tr(label), name) if label == "all_cells": self.zone = name if not self.zone: self.zone = name self.modelZone.setItem(str_model = self.zone) self.modelTurbulence = ComboModel(self.comboBoxTurbulence, 2, 1) self.modelTurbulence.addItem(self.tr("Initialization by formula"), 'formula') self.modelTurbulence.addItem(self.tr("Initialization by reference value(s)"), 'reference_value') # 2/ Connections self.connect(self.comboBoxZone, SIGNAL("activated(const QString&)"), self.slotZone) self.connect(self.comboBoxTurbulence, SIGNAL("activated(const QString&)"), self.slotChoice) self.connect(self.comboBoxSpecies, SIGNAL("activated(const QString&)"), self.slotSpeciesChoice) self.connect(self.comboBoxMeteo, SIGNAL("activated(const QString&)"), self.slotMeteoChoice) self.connect(self.checkBoxPressure, SIGNAL("clicked()"), self.slotPressure) self.connect(self.checkBoxDensity, SIGNAL("clicked()"), self.slotDensity) self.connect(self.checkBoxTemperature, SIGNAL("clicked()"), self.slotTemperature) self.connect(self.checkBoxEnergy, SIGNAL("clicked()"), self.slotEnergy) self.connect(self.pushButtonVelocity, SIGNAL("clicked()"), self.slotVelocityFormula) self.connect(self.pushButtonThermal, SIGNAL("clicked()"), self.slotThermalFormula) self.connect(self.pushButtonTurbulence, SIGNAL("clicked()"), self.slotTurbulenceFormula) self.connect(self.pushButtonSpecies, SIGNAL("clicked()"), self.slotSpeciesFormula) self.connect(self.pushButtonMeteo, SIGNAL("clicked()"), self.slotMeteoFormula) self.connect(self.pushButtonPressure, SIGNAL("clicked()"), self.slotPressureFormula) self.connect(self.pushButtonDensity, SIGNAL("clicked()"), self.slotDensityFormula) self.connect(self.pushButtonTemperature,SIGNAL("clicked()"), self.slotTemperatureFormula) self.connect(self.pushButtonEnergy, SIGNAL("clicked()"), self.slotEnergyFormula) self.connect(self.pushButtonPressure_2, SIGNAL("clicked()"), self.slotPressureFormula) choice = self.init.getInitialTurbulenceChoice(self.zone) self.modelTurbulence.setItem(str_model = choice) # species treatment self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.scalar = "" scalar_list = self.th_sca.getUserScalarNameList() for s in self.th_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for item in self.species_group: item.show() for scalar in scalar_list: self.modelSpecies.addItem(self.tr(scalar), scalar) self.modelSpecies.setItem(str_model = self.scalar) setGreenColor(self.pushButtonSpecies, True) else: for item in self.species_group: item.hide() # meteo self.modelMeteo = ComboModel(self.comboBoxMeteo, 1, 1) self.scalar_meteo = "" scalar_meteo_list = DefineUserScalarsModel( self.case).getMeteoScalarsNameList() if scalar_meteo_list != None and scalar_meteo_list != []: self.scalar_meteo = scalar_meteo_list[0] for item in self.meteo_group: item.show() for scalar in scalar_meteo_list: self.modelMeteo.addItem(self.tr(scalar), scalar) self.modelMeteo.setItem(str_model = self.scalar_meteo) setGreenColor(self.pushButtonMeteo, True) else: for item in self.meteo_group: item.hide() if DarcyModel(self.case).getDarcyModel() == "off": self.labelpressure.hide() self.pushButtonPressure_2.hide() else: setGreenColor(self.pushButtonPressure_2, True) # Initialize widget self.initializeVariables(self.zone) self.case.undoStartGlobal() @pyqtSignature("const QString&") def slotZone(self, text): """ INPUT label for choice of zone """ self.zone = self.modelZone.dicoV2M[str(text)] self.initializeVariables(self.zone) @pyqtSignature("const QString&") def slotChoice(self, text): """ INPUT choice of method of initialization """ choice = self.modelTurbulence.dicoV2M[str(text)] log.debug("slotChoice choice = %s "%str(choice)) self.init.setInitialTurbulenceChoice(self.zone, choice) turb_model = self.turb.getTurbulenceModel() self.initializeVariables(self.zone) @pyqtSignature("const QString&") def slotMeteoChoice(self, text): """ INPUT label for choice of zone """ self.scalar_meteo= self.modelMeteo.dicoV2M[str(text)] self.initializeVariables(self.zone) setGreenColor(self.pushButtonMeteo, True) @pyqtSignature("const QString&") def slotSpeciesChoice(self, text): """ INPUT label for choice of zone """ self.scalar= self.modelSpecies.dicoV2M[str(text)] self.initializeVariables(self.zone) setGreenColor(self.pushButtonSpecies, True) @pyqtSignature("const QString&") def slotVelocityFormula(self): """ """ exp = self.init.getVelocityFormula(self.zone) if not exp: exp = self.init.getDefaultVelocityFormula() exa = """#example: \n""" + self.init.getDefaultVelocityFormula() req = [('velocity[0]', "velocity"), ('velocity[1]', "velocity"), ('velocity[2]', "velocity")] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotFormulaVelocity -> %s" % str(result)) self.init.setVelocityFormula(self.zone, result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotTurbulenceFormula(self): """ INPUT user formula """ turb_model = self.turb.getTurbulenceModel() exa = """#example \n""" + self.init.getDefaultTurbFormula(turb_model) exp = self.init.getTurbFormula(self.zone, turb_model) sym = [('rho0', 'density (reference value)'), ('mu0', 'viscosity (reference value)'), ('cp0', 'specific heat (reference value)'), ('lambda0', 'thermal conductivity (reference value)'), ('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'), ('uref','reference velocity'), ('almax','reference length')] if turb_model in ('k-epsilon', 'k-epsilon-PL'): req = [('k', "turbulent energy"), ('epsilon', "turbulent dissipation")] elif turb_model in ('Rij-epsilon', 'Rij-SSG'): req = [('r11', "Reynolds stress R11"), ('r22', "Reynolds stress R22"), ('r33', "Reynolds stress R33"), ('r12', "Reynolds stress R12"), ('r23', "Reynolds stress R23"), ('r13', "Reynolds stress R13"), ('epsilon', "turbulent dissipation")] elif turb_model == 'Rij-EBRSM': req = [('r11', "Reynolds stress R11"), ('r22', "Reynolds stress R22"), ('r33', "Reynolds stress R33"), ('r12', "Reynolds stress R12"), ('r23', "Reynolds stress R23"), ('r13', "Reynolds stress R13"), ('epsilon', "turbulent dissipation"), ('alpha', "alpha")] elif turb_model == 'v2f-BL-v2/k': req = [('k', "turbulent energy"), ('epsilon', "turbulent dissipation"), ('phi', "variable phi in v2f model"), ('alpha', "variable alpha in v2f model")] elif turb_model == 'k-omega-SST': req = [('k', "turbulent energy"), ('omega', "specific dissipation rate")] elif turb_model == 'Spalart-Allmaras': req = [('nu_tilda', "nusa")] 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("slotFormulaTurb -> %s" % str(result)) self.init.setTurbFormula(self.zone, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString&") def slotThermalFormula(self): """ Input the initial formula of thermal scalar """ exp = self.init.getThermalFormula(self.zone) if not exp: exp = self.init.getDefaultThermalFormula() exa = """#example \n""" + self.init.getDefaultThermalFormula() if self.therm.getThermalScalarModel() == "enthalpy": req = [('enthalpy', 'enthalpy')] elif self.therm.getThermalScalarModel() == "total_energy": req = [('total_energy', 'total energy')] else: req = [('temperature', 'temperature')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotFormulaThermal -> %s" % str(result)) self.init.setThermalFormula(self.zone, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString&") def slotSpeciesFormula(self): """ Input the initial formula of species """ exp = self.init.getSpeciesFormula(self.zone, self.scalar) name = self.th_sca.getScalarName(self.scalar) if not exp: exp = str(name)+""" = 0;\n""" exa = """#example: \n""" + str(name)+""" = 0;\n""" req = [(str(name), str(name))] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotFormulaSpecies -> %s" % str(result)) self.init.setSpeciesFormula(self.zone, self.scalar, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString&") def slotMeteoFormula(self): """ """ exp = self.init.getMeteoFormula(self.zone, self.scalar_meteo) name = self.scalar_meteo if not exp: exp = str(name)+""" = 0;\n""" exa = """#example: \n""" + str(name)+""" = 0;\n""" req = [(str(name), str(name))] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotFormulaMeteo -> %s" % str(result)) self.init.setMeteoFormula(self.zone, self.scalar_meteo, result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotPressure(self): """ Pressure selected or not for the initialisation. """ if self.checkBoxPressure.isChecked(): self.init.setPressureStatus(self.zone,"on") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonPressure.setEnabled(True) setGreenColor(self.pushButtonPressure,True) if len(box_list) == 2: for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(False) else: self.init.setPressureStatus(self.zone,"off") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonPressure.setEnabled(False) setGreenColor(self.pushButtonPressure,False) if len(box_list) == 1: for name in self.thermodynamic_list: if name != 'Pressure': __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(True) if box_list[0] =='Energy': self.checkBoxTemperature.setEnabled(False) if box_list[0] =='Temperature': self.checkBoxEnergy.setEnabled(False) @pyqtSignature("") def slotDensity(self): """ Density selected or not for the initialisation. """ if self.checkBoxDensity.isChecked(): self.init.setDensityStatus(self.zone,"on") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonDensity.setEnabled(True) setGreenColor(self.pushButtonDensity,True) if len(box_list) == 2: for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(False) else: self.init.setDensityStatus(self.zone,"off") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonDensity.setEnabled(False) setGreenColor(self.pushButtonDensity,False) if len(box_list) == 1: for name in self.thermodynamic_list: if name != 'Density': __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(True) if box_list[0] =='Energy': self.checkBoxTemperature.setEnabled(False) if box_list[0] =='Temperature': self.checkBoxEnergy.setEnabled(False) @pyqtSignature("") def slotTemperature(self): """ Temperature selected or not for the initialisation. """ if self.checkBoxTemperature.isChecked(): self.init.setTemperatureStatus(self.zone,"on") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonTemperature.setEnabled(True) setGreenColor(self.pushButtonTemperature,True) if len(box_list) == 2: for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(False) self.checkBoxEnergy.setEnabled(False) else: self.init.setTemperatureStatus(self.zone,"off") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonTemperature.setEnabled(False) setGreenColor(self.pushButtonTemperature,False) if len(box_list) == 1: for name in self.thermodynamic_list: if name != 'Temperature': __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(True) self.checkBoxEnergy.setEnabled(True) @pyqtSignature("") def slotEnergy(self): """ Energy selected or not for the initialisation. """ if self.checkBoxEnergy.isChecked(): self.init.setEnergyStatus(self.zone,"on") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonEnergy.setEnabled(True) setGreenColor(self.pushButtonEnergy,True) if len(box_list) == 2: for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setEnabled(False) __Button.setEnabled(False) setGreenColor(__Button,False) if len(box_list) == 1: self.checkBoxTemperature.setEnabled(False) else: self.init.setEnergyStatus(self.zone,"off") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonEnergy.setEnabled(False) setGreenColor(self.pushButtonEnergy,False) if len(box_list) == 1: for name in self.thermodynamic_list: if name != 'Energy': __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setEnabled(True) __Button.setEnabled(False) setGreenColor(__Button,False) self.checkBoxTemperature.setEnabled(True) @pyqtSignature("const QString&") def slotPressureFormula(self): """ Input the initial Pressure formula """ exp = self.init.getPressureFormula(self.zone) if not exp: exp = """p0 = 0.; g = 9.81; ro = 1.17862; pressure = p0 + g * ro * z;\n""" exa = """#example: """ req = [('pressure', 'pressure')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotPressureFormula -> %s" % str(result)) self.init.setPressureFormula(self.zone, result) setGreenColor(self.pushButtonPressure_2, False) @pyqtSignature("const QString&") def slotDensityFormula(self): """ Input the initial Density formula """ exp = self.init.getDensityFormula(self.zone) if not exp: exp = """density = 0;\n""" exa = """#example: """ req = [('density', 'density')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotDensityFormula -> %s" % str(result)) self.init.setDensityFormula(self.zone, result) setGreenColor(self.pushButtonDensity, False) @pyqtSignature("const QString&") def slotTemperatureFormula(self): """ Input the initial Temperature formula """ exp = self.init.getTemperatureFormula(self.zone) if not exp: exp = """temperature = 0;\n""" exa = """#example: """ req = [('temperature', 'temperature')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotTemperatureFormula -> %s" % str(result)) self.init.setTemperatureFormula(self.zone, result) setGreenColor(self.pushButtonTemperature, False) @pyqtSignature("const QString&") def slotEnergyFormula(self): """ Input the initial Energy formula """ exp = self.init.getEnergyFormula(self.zone) if not exp: exp = """total_energy = 0;\n""" exa = """#example: """ req = [('total_energy', 'Energy')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] 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("slotEnergyFormula -> %s" % str(result)) self.init.setEnergyFormula(self.zone, result) setGreenColor(self.pushButtonEnergy, False) def initializeVariables(self, zone): """ Initialize variables when a new volumic zone is choosen """ # Initialisation of Turbulence turb_model = self.turb.getTurbulenceModel() if turb_model not in ('k-epsilon', 'k-epsilon-PL', 'Rij-epsilon', 'Rij-SSG', 'Rij-EBRSM', 'v2f-BL-v2/k', 'k-omega-SST', 'Spalart-Allmaras'): for item in self.turb_group: item.hide() else: for item in self.turb_group: item.show() turb_init = self.init.getInitialTurbulenceChoice(self.zone) self.modelTurbulence.setItem(str_model = turb_init) if turb_init == 'formula': self.pushButtonTurbulence.setEnabled(True) turb_formula = self.init.getTurbFormula(zone, turb_model) if not turb_formula: turb_formula = self.init.getDefaultTurbFormula(turb_model) self.init.setTurbFormula(zone, turb_formula) setGreenColor(self.pushButtonTurbulence, True) else: self.pushButtonTurbulence.setEnabled(False) setGreenColor(self.pushButtonTurbulence, False) #velocity velocity_formula = self.init.getVelocityFormula(zone) if not velocity_formula: velocity_formula = self.init.getDefaultVelocityFormula() self.init.setVelocityFormula(zone, velocity_formula) setGreenColor(self.pushButtonVelocity, True) # Initialisation of Model Variables if thermal model is selectionned for item in self.thermal_group: item.hide() model = self.therm.getThermalScalarModel() if model != "off" and self.comp.getCompressibleModel() == 'off': for item in self.thermal_group: item.show() th_formula = self.init.getThermalFormula(zone) if not th_formula: th_formula = self.init.getDefaultThermalFormula() self.init.setThermalFormula(zone, th_formula) setGreenColor(self.pushButtonThermal, True) # Initialisation of the termodynamics values for the compressible model if self.comp.getCompressibleModel() != 'off': nb_box = 0 box_list = self.init.getCheckedBoxList(self.zone) if box_list == []: for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setChecked(False) __Button.setEnabled(False) setGreenColor(__Button, False) elif len(box_list) == 1: box = box_list[0] for name in self.thermodynamic_list: if name != box: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setChecked(False) __Button.setEnabled(False) setGreenColor(__Button,False) if box == 'Temperature': self.checkBoxEnergy.setEnabled(False) elif box == 'Energy': self.checkBoxTemperature.setEnabled(False) __checkBox = getattr(self, "checkBox" + box) __checkBox.setChecked(True) __Button = getattr(self, "pushButton" + box) __Button.setEnabled(True) setGreenColor(__Button, True) elif len(box_list) == 2: box1 = box_list[0] box2 = box_list[1] for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setChecked(False) __checkBox.setEnabled(False) __Button.setEnabled(False) for name in box_list: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setChecked(True) __Button.setEnabled(True) setGreenColor(__Button, True) def tr(self, text): """ Translation """ return text
class SourceTermsView(QWidget, Ui_SourceTermsForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_SourceTermsForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.parent = parent self.mdl = SourceTermsModel(self.case) self.therm = ThermalScalarModel(self.case) self.th_sca = DefineUserScalarsModel(self.case) self.volzone = LocalizationModel('VolumicZone', self.case) self.m_out = OutputVolumicVariablesModel(self.case) # 0/ Read label names from XML file # Velocity # Thermal scalar namesca, unit = self.getThermalLabelAndUnit() self.th_sca_name = namesca # 1/ Combo box models self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.modelZone = ComboModel(self.comboBoxZone, 1, 1) self.zone = "" zones = self.volzone.getZones() for zone in zones: active = 0 if (zone.getNature()['momentum_source_term'] == "on"): active = 1 if ('thermal_source_term' in zone.getNature().keys()): if (zone.getNature()['thermal_source_term'] == "on"): active = 1 if ('scalar_source_term' in zone.getNature().keys()): if (zone.getNature()['scalar_source_term'] == "on"): active = 1 if (active): label = zone.getLabel() name = str(zone.getCodeNumber()) self.modelZone.addItem(self.tr(label), name) if label == "all_cells": self.zone = name if not self.zone: self.zone = name self.modelZone.setItem(str_model = self.zone) # 2/ Connections self.connect(self.comboBoxZone, SIGNAL("activated(const QString&)"), self.slotZone) self.connect(self.comboBoxSpecies, SIGNAL("activated(const QString&)"), self.slotSpeciesChoice) self.connect(self.pushButtonMomentum, SIGNAL("clicked()"), self.slotMomentumFormula) self.connect(self.pushButtonThermal, SIGNAL("clicked()"), self.slotThermalFormula) self.connect(self.pushButtonSpecies, SIGNAL("clicked()"), self.slotSpeciesFormula) # 3/ Initialize widget self.initialize(self.zone) self.case.undoStartGlobal() def initialize(self, zone_num): """ Initialize widget when a new volumic zone is choosen """ zone = self.case.xmlGetNode("zone", id=zone_num) if zone['momentum_source_term'] == "on": self.labelMomentum.show() self.pushButtonMomentum.show() setGreenColor(self.pushButtonMomentum, True) else: self.labelMomentum.hide() self.pushButtonMomentum.hide() if zone['thermal_source_term'] == "on": self.pushButtonThermal.show() self.labelThermal.show() setGreenColor(self.pushButtonThermal, True) else: self.pushButtonThermal.hide() self.labelThermal.hide() if zone['scalar_source_term'] == "on": self.comboBoxSpecies.show() self.pushButtonSpecies.show() self.labelSpecies.show() setGreenColor(self.pushButtonSpecies, True) self.scalar = "" scalar_list = self.th_sca.getUserScalarNameList() for s in self.th_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: for scalar in scalar_list: self.scalar = scalar self.modelSpecies.addItem(self.tr(scalar),self.scalar) self.modelSpecies.setItem(str_model = self.scalar) else: self.comboBoxSpecies.hide() self.pushButtonSpecies.hide() self.labelSpecies.hide() @pyqtSignature("const QString&") def slotZone(self, text): """ INPUT label for choice of zone """ self.zone = self.modelZone.dicoV2M[str(text)] self.initialize(self.zone) @pyqtSignature("const QString&") def slotSpeciesChoice(self, text): """ INPUT label for choice of zone """ self.scalar= self.modelSpecies.dicoV2M[str(text)] setGreenColor(self.pushButtonSpecies, True) @pyqtSignature("const QString&") def slotMomentumFormula(self): """ Set momentumFormula of the source term """ exp = self.mdl.getMomentumFormula(self.zone) if not exp: exp = """Su = 0;\nSv = 0;\nSw = 0;\n dSudu = 0;\ndSudv = 0;\ndSudw = 0;\n dSvdu = 0;\ndSvdv = 0;\ndSvdw = 0;\n dSwdu = 0;\ndSwdv = 0;\ndSwdw = 0;\n""" exa = """#example: """ req = [('Su', "x velocity"), ('Sv', "y velocity"), ('Sw', "z velocity"), ('dSudu', "x component x velocity derivative"), ('dSudv', "x component y velocity derivative"), ('dSudw', "x component z velocity derivative"), ('dSvdu', "y component x velocity derivative"), ('dSvdv', "y component y velocity derivative"), ('dSvdw', "y component z velocity derivative"), ('dSwdu', "z component x velocity derivative"), ('dSwdv', "z component y velocity derivative"), ('dSwdw', "z component z velocity derivative")] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] sym.append( ("velocity[0]", 'X velocity component')) sym.append( ("velocity[1]", 'Y velocity component')) sym.append( ("velocity[2]", 'Z velocity component')) 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("slotFormulaVelocity -> %s" % str(result)) self.mdl.setMomentumFormula(self.zone, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString&") def slotSpeciesFormula(self): """ """ exp = self.mdl.getSpeciesFormula(self.zone, self.scalar) if not exp: exp = """S = 0;\ndS = 0;\n""" exa = """#example: """ req = [('S', 'species source term'), ('dS', 'species source term derivative')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] name = self.th_sca.getScalarName(self.scalar) sym.append((name, 'current species')) 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("slotFormulaSpecies -> %s" % str(result)) self.mdl.setSpeciesFormula(self.zone, self.scalar, result) setGreenColor(self.sender(), False) def getThermalLabelAndUnit(self): """ Define the type of model is used. """ model = self.therm.getThermalScalarModel() if model != 'off': th_sca_name = self.therm.getThermalScalarName() if model == "temperature_celsius": unit = "<sup>o</sup>C" elif model == "temperature_kelvin": unit = "Kelvin" elif model == "enthalpy": unit = "J/kg" else: th_sca_name = '' unit = None self.th_sca_name = th_sca_name return th_sca_name, unit @pyqtSignature("const QString&") def slotThermalFormula(self): """ Input the initial formula of thermal scalar """ exp = self.mdl.getThermalFormula(self.zone, self.th_sca_name) if not exp: exp = self.mdl.getDefaultThermalFormula(self.th_sca_name) exa = """#example: """ req = [('S', 'thermal source term'), ('dS', 'thermal source term derivative')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] if self.therm.getThermalScalarModel() == 'enthalpy': sym.append(('enthalpy', 'thermal scalar')) if self.therm.getThermalScalarModel() == 'total_energy': sym.append(('total_energy', 'thermal scalar')) else: sym.append(('temperature', 'thermal scalar')) 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("slotFormulaThermal -> %s" % str(result)) self.mdl.setThermalFormula(self.zone, self.th_sca_name, result) setGreenColor(self.sender(), False) def tr(self, text): """ Translation """ return text
class LagrangianAdvancedOptionsDialogView(QDialog, Ui_LagrangianAdvancedOptionsDialogForm): """ Advanced dialog """ def __init__(self, parent, case, default): """ Constructor """ QDialog.__init__(self, parent) Ui_LagrangianAdvancedOptionsDialogForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.setWindowTitle(self.tr("Advanced options")) self.default = default self.result = self.default.copy() # Combo model self.modelNORDRE = ComboModel(self.comboBoxNORDRE, 2, 1) self.modelNORDRE.addItem(self.tr("first-order scheme"), "1") self.modelNORDRE.addItem(self.tr("second-order scheme"), "2") self.modelIDIRLA = ComboModel(self.comboBoxIDIRLA, 3, 1) self.modelIDIRLA.addItem(self.tr("X"), "1") self.modelIDIRLA.addItem(self.tr("Y"), "2") self.modelIDIRLA.addItem(self.tr("Z"), "3") # Connections self.connect(self.comboBoxNORDRE, SIGNAL("activated(const QString&)"), self.slotNORDRE) self.connect(self.checkBoxIDISTU, SIGNAL("clicked()"), self.slotIDISTU) self.connect(self.checkBoxIDIFFL, SIGNAL("clicked()"), self.slotIDIFFL) self.connect(self.groupBoxModel, SIGNAL("clicked(bool)"), self.slotModel) self.connect(self.lineEditMODCPL, SIGNAL("textChanged(const QString &)"), self.slotMODCPL) self.connect(self.comboBoxIDIRLA, SIGNAL("activated(const QString&)"), self.slotIDIRLA) validatorMODCPL = IntValidator(self.lineEditMODCPL, min=1) self.lineEditMODCPL.setValidator(validatorMODCPL) # initialize Widgets order = str(self.result['scheme_order']) self.modelNORDRE.setItem(str_model=order) if self.result['turbulent_dispertion'] == "on": self.checkBoxIDISTU.setChecked(True) else: self.checkBoxIDISTU.setChecked(False) if self.result['fluid_particles_turbulent_diffusion'] == "on": self.checkBoxIDIFFL.setChecked(True) else: self.checkBoxIDIFFL.setChecked(False) value = self.result['complete_model_iteration'] if value > 0: self.lineEditMODCPL.setText(str(value)) direction = self.result['complete_model_direction'] self.modelIDIRLA.setItem(str_model=str(direction)) else: self.groupBoxModel.setChecked(False) self.case.undoStartGlobal() @pyqtSignature("const QString&") def slotNORDRE(self, text): """ Input NORDRE. """ value = self.modelNORDRE.dicoV2M[str(text)] self.result['scheme_order'] = value @pyqtSignature("") def slotIDISTU(self): """ Input IDISTU. """ if self.checkBoxIDISTU.isChecked(): status = "on" else: status = "off" self.result['turbulent_dispertion'] = status @pyqtSignature("") def slotIDIFFL(self): """ Input IDIFFL. """ if self.checkBoxIDIFFL.isChecked(): status = "on" else: status = "off" self.result['fluid_particles_turbulent_diffusion'] = status @pyqtSignature("bool") def slotModel(self, checked): if checked: value = self.default['complete_model_iteration'] if value == 0: value = 1 self.result['complete_model_iteration'] = value self.lineEditMODCPL.setText(str(value)) else: self.result['complete_model_iteration'] = 0 @pyqtSignature("const QString&") def slotMODCPL(self, text): """ Input MODCPL. """ if self.sender().validator().state == QValidator.Acceptable: self.result['complete_model_iteration'] = from_qvariant(text, int) @pyqtSignature("const QString&") def slotIDIRLA(self, text): """ Input IDIRLA. """ value = self.modelIDIRLA.dicoV2M[str(text)] self.result['complete_model_direction'] = value def get_result(self): """ Method to get the result """ return self.result def accept(self): """ Method called when user clicks 'OK' """ QDialog.accept(self) def reject(self): """ Method called when user clicks 'Cancel' """ self.result = self.default.copy() QDialog.reject(self) def tr(self, text): """ Translation """ return text
class TimeAveragesView(QWidget, Ui_TimeAveragesForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_TimeAveragesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = TimeAveragesModel(self.case) self.entriesNumber = 0 self.label_select = None # Create the Page layout. # Models self.modelAverage = StandardItemModelAverage(self) self.treeViewAverage.setModel(self.modelAverage) self.treeViewAverage.resizeColumnToContents(0) self.treeViewAverage.resizeColumnToContents(1) self.treeViewAverage.resizeColumnToContents(2) self.treeViewAverage.resizeColumnToContents(3) self.treeViewAverage.resizeColumnToContents(4) self.modelDrag = QStringListModel() self.modelDrop = QStringListModel() self.listViewDrag.setModel(self.modelDrag) self.listViewDrop.setModel(self.modelDrop) self.listViewDrag.setAlternatingRowColors(True) self.listViewDrag.setEditTriggers(QAbstractItemView.NoEditTriggers) self.listViewDrop.setAlternatingRowColors(True) self.listViewDrop.setEditTriggers(QAbstractItemView.NoEditTriggers) self.modelIMOOLD = ComboModel(self.comboBoxIMOOLD, 3, 1) self.modelIMOOLD.addItem(self.tr('automatic'), 'automatic') self.modelIMOOLD.addItem(self.tr('reset'), 'reset') self.modelIMOOLD.addItem(self.tr('specified'), 'specified') self.modelStartType = ComboModel(self.comboBoxStartType, 2, 1) self.modelStartType.addItem(self.tr('time'), 'time') self.modelStartType.addItem(self.tr('iteration'), 'iteration') # Connections self.connect(self.pushButtonAdd, SIGNAL("clicked()"), self.slotAddAverage) self.connect(self.pushButtonDelete, SIGNAL("clicked()"), self.slotdeleteTimeAverage) self.connect(self.pushButtonAddVar, SIGNAL("clicked()"), self.slotAddVarAverage) self.connect(self.pushButtonSuppressVar, SIGNAL("clicked()"), self.slotDeleteVarAverage) self.connect(self.treeViewAverage, SIGNAL("pressed(const QModelIndex &)"), self.slotSelectAverage) self.connect(self.lineEditStart, SIGNAL("textChanged(const QString &)"), self.slotStart) self.connect(self.lineEditStartTime, SIGNAL("textChanged(const QString &)"), self.slotStartTime) self.connect(self.comboBoxIMOOLD, SIGNAL("activated(const QString&)"), self.slotRestartChoice) self.connect(self.comboBoxStartType, SIGNAL("activated(const QString&)"), self.slotTimeChoice) self.connect(self.lineEditRestart, SIGNAL("textChanged(const QString &)"), self.slotRestart) self.connect(self.lineEditAverage, SIGNAL("textChanged(const QString &)"), self.slotBaseName) # Validators validatorStart = IntValidator(self.lineEditStart, min=-1) self.lineEditStart.setValidator(validatorStart) validatorStartTime = DoubleValidator(self.lineEditStartTime, min=-1.) self.lineEditStartTime.setValidator(validatorStartTime) validatorRestart = IntValidator(self.lineEditRestart, min=-2, max=50) validatorRestart.setExclusiveValues([0]) self.lineEditRestart.setValidator(validatorRestart) rx = "[\-_A-Za-z0-9]{1," + str(LABEL_LENGTH_MAX) + "}" validatorLabel = RegExpValidator(self.lineEditAverage, QRegExp(rx)) self.lineEditAverage.setValidator(validatorLabel) # Initialize # Update list of variables, properties, scalars ... lst_label = [str(label) for label in list(self.mdl.dicoLabel2Name.keys())] self.modelDrag.setStringList(sorted(lst_label, key=str.lower)) # Is it a following calculation ? if not StartRestartModel(self.case).getRestartPath(): self.labelRestart.setDisabled(True) self.comboBoxIMOOLD.setDisabled(True) self.lineEditRestart.setDisabled(True) self.treeViewAverage.hideColumn(4) else: self.slotRestartChoice("automatic") # Update list of averages for view from xml file for nb in range(self.mdl.getNumberOfTimeAverage()): self.entriesNumber = self.entriesNumber + 1 label, start, timestart, restart, lst = self.mdl.getTimeAverageData(nb+1) self.insertAverage(label, start, timestart, restart, lst) self.groupBoxTimeAverage.hide() self.case.undoStartGlobal() @pyqtSignature("const QString&") def slotStart(self, text): """ Return an integer for ntdmom, value of start of calculation. """ if self.sender().validator().state == QValidator.Acceptable: start = from_qvariant(text, int) else: start = self.mdl.defaultValues()['start'] self.mdl.setTimeStepStart(self.label_select, start) self.updateView() @pyqtSignature("const QString&") def slotStartTime(self, text): """ Return an float for ttdmom, value of start of calculation. """ if self.sender().validator().state == QValidator.Acceptable: start = from_qvariant(text, float) timestart = start else: timestart = self.mdl.defaultValues()['timestart'] self.mdl.setTimeStart(self.label_select, timestart) self.updateView() @pyqtSignature("const QString&") def slotRestartChoice(self, text): choice = self.modelIMOOLD.dicoV2M[str(text)] if choice == "automatic": restart = -2 self.lineEditRestart.setDisabled(True) self.lineEditRestart.setText(str(restart)) elif choice == "reset": restart = -1 self.lineEditRestart.setDisabled(True) self.lineEditRestart.setText(str(restart)) elif choice == "specified": restart = self.mdl.defaultValues()['restart'] self.lineEditRestart.setDisabled(False) self.lineEditRestart.setText(str(restart)) if self.label_select: self.mdl.setRestart(self.label_select, restart) self.updateView() @pyqtSignature("const QString&") def slotTimeChoice(self, text): choice = self.modelStartType.dicoV2M[str(text)] self.modelStartType.setItem(str_model=choice) if choice == "time": start = -1 self.mdl.setTimeStepStart(self.label_select, start) timestart = self.mdl.getTimeStart(self.label_select) self.lineEditStart.setText(str(start)) self.lineEditStartTime.setText(str(timestart)) self.lineEditStart.hide() self.labelStart.hide() self.lineEditStartTime.show() self.labelStartTime.show() elif choice == "iteration": timestart = -1. self.mdl.setTimeStart(self.label_select, timestart) start = self.mdl.getTimeStepStart(self.label_select) self.lineEditStart.setText(str(start)) self.lineEditStartTime.setText(str(timestart)) self.lineEditStart.show() self.labelStart.show() self.lineEditStartTime.hide() self.labelStartTime.hide() self.updateView() @pyqtSignature("const QString&") def slotRestart(self, text): """ Return an integer for imoold, value of restart of calculation. """ if self.sender().validator().state == QValidator.Acceptable: restart = from_qvariant(text, int) else: restart = self.mdl.defaultValues()['restart'] if self.label_select: self.mdl.setRestart(self.label_select, restart) self.updateView() def averageInfo(self): """ Return info from the argument entry. """ row = self.treeViewAverage.currentIndex().row() return self.modelAverage.getItem(row) def insertAverage(self, label, ntdmom, ttdmom, imoold, lst): """ Insert values in Hlist. """ if len(lst) > 0: idfmom = "*".join(lst) idfmom_view = "<" + idfmom +">" else: idfmom_view = "" if imoold == self.mdl.defaultValues()['restart']: imoold = "" self.modelAverage.addItem(label, ntdmom, ttdmom, imoold, idfmom_view) @pyqtSignature("") def slotAddAverage(self): """ Set in view IMOM, NTDMOM, IMOOLD, IDFMOM """ var_prop = [] label, ntdmom, ttdmom, imoold = self.mdl.addTimeAverage() self.insertAverage(label, ntdmom, ttdmom, imoold, var_prop) self.__eraseEntries() @pyqtSignature("") def slotdeleteTimeAverage(self): """ Delete the selected average from the list (one by one). """ row = self.treeViewAverage.currentIndex().row() log.debug("slotdeleteTimeAverage -> %s" % (row,)) if row == -1: title = self.tr("Warning") msg = self.tr("You must select an existing time average") QMessageBox.information(self, title, msg) else: [imom, label, ntdmom, ttdmom, imoold, idfmom] = self.averageInfo() self.mdl.deleteTimeAverage(label) self.modelAverage.deleteAllData() for n in range(self.mdl.getNumberOfTimeAverage()): label, ntdmom, ttdmom, imoold, var_prop = self.mdl.getTimeAverageData(n+1) self.insertAverage(label, ntdmom, ttdmom, imoold, var_prop) self.__eraseEntries() @pyqtSignature("const QModelIndex &") def slotSelectAverage(self, index): """ Return the selected item from the Hlist. """ self.groupBoxTimeAverage.show() row = index.row() log.debug("slotSelectAverage -> %s" % (row,)) [imom, label, ntdmom, ttdmom, imoold, idfmom] = self.averageInfo() self.label_select = label self.lineEditAverage.setText(str(label)) self.lineEditStart.setText(str(ntdmom)) self.lineEditStartTime.setText(str(ttdmom)) if ntdmom == -1: self.slotTimeChoice("time") else: self.slotTimeChoice("iteration") if StartRestartModel(self.case).getRestartPath(): if not imoold or imoold == -2: imoold = -2 choice = "automatic" elif imoold == -1: choice = "reset" else: choice = "specified" self.slotRestartChoice(str(choice)) self.modelIMOOLD.setItem(str_model=choice) self.lineEditRestart.setText(str(imoold)) lst = [str(s) for s in idfmom.replace('>','').replace('<','').split('*')] if lst[0] == "": lst.remove(lst[0]) self.modelDrop.setStringList(lst) @pyqtSignature("") def slotAddVarAverage(self): """ Add a new var from list to profile """ if (self.listViewDrag.currentIndex().row() >=0) : lst = self.modelDrop.stringList() var = self.modelDrag.stringList()[self.listViewDrag.currentIndex().row()] lst.append(var) self.modelDrop.setStringList(lst) lst = [str(s) for s in lst] if lst[0] == "": lst.remove(lst[0]) self.mdl.setVariable(self.label_select, lst) self.updateView() @pyqtSignature("") def slotDeleteVarAverage(self): """ Supress a var from profile """ self.modelDrop.removeRows(self.listViewDrop.currentIndex().row(), 1) liste = self.modelDrop.stringList() liste = [str(s) for s in liste] self.mdl.setVariable(self.label_select, liste) self.updateView() @pyqtSignature("const QString&") def slotBaseName(self, text): """ """ if self.sender().validator().state == QValidator.Acceptable: self.mdl.setLabel(self.label_select, str(text)) self.label_select = str(text) self.updateView() def updateView(self): row = self.treeViewAverage.currentIndex().row() if self.label_select: lst = self.mdl.getVariable(self.label_select) ntdmom = self.mdl.getTimeStepStart(self.label_select) ttdmom = self.mdl.getTimeStart(self.label_select) imoold = self.mdl.getRestart(self.label_select) idfmom = "*".join(lst) idfmom_view = "<" + idfmom +">" self.modelAverage.replaceItem(row, self.label_select, ntdmom, ttdmom, imoold, idfmom_view) def __eraseEntries(self): """ Delete all caracters in the entries. """ self.label_select = None self.treeViewAverage.clearSelection() self.groupBoxTimeAverage.hide() def tr(self, text): """ Translation """ return text
class NucleateBoilingView(QWidget, Ui_NucleateBoiling): """ Nucleate boiling model layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_NucleateBoiling.__init__(self) self.setupUi(self) 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") 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() @pyqtSlot(str) def slotHeatTransferModel(self, text): """ configure standard or extend kurul-podowski model """ value = self.modelHeatTransferModel.dicoV2M[text] log.debug("slotHeatTransferModel -> %s" % value) self.mdl.setHeatTransferModel(value) if value == "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) self.lineEditMaxRadius.setText(str(self.mdl.getMaxRadius())) self.lineEditMaxDiam.setText(str(self.mdl.getMaxDiameter())) @pyqtSlot(str) def slotWallFunctionModel(self, text): """ configure wall function model """ value = self.modelWallFunctionModel.dicoV2M[text] log.debug("slotWallFunctionModel -> %s" % value) self.mdl.setWallFunctionModel(value) @pyqtSlot(str) def slotYPlus(self, text): """ configure Y Plus model """ value = self.modelYPlus.dicoV2M[text] log.debug("slotYPlus -> %s" % value) self.mdl.setYPlusModel(value) if value == "Yplus_value": self.lineEditYPlus.show() self.lineEditYPlus.setText(str(self.mdl.getYPlusValue())) else: self.lineEditYPlus.hide() @pyqtSlot(str) def slotYPlusValue(self, text): """ Update the Yplus value """ if self.lineEditYPlus.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setYPlusValue(value) @pyqtSlot(str) def slotMaxRadius(self, text): """ Update the max radius """ if self.lineEditMaxRadius.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMaxRadius(value) @pyqtSlot(str) def slotMaxDiam(self, text): """ Update the max diameter """ if self.lineEditMaxDiam.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMaxDiameter(value) @pyqtSlot(str) def slotMaxOverSaturation(self, text): """ Update the maximum oversaturation temperature """ if self.lineEditMaxOverSaturation.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMaxOverSaturation(value) @pyqtSlot(str) def slotThermalConductivity(self, text): """ Update the thermal conductivity """ if self.lineEditThermalConductivity.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setThermalConductivity(value) @pyqtSlot(str) def slotDensity(self, text): """ Update the density """ if self.lineEditDensity.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setDensity(value) @pyqtSlot(str) def slotSpecificHeat(self, text): """ Update the specific heat """ if self.lineEditSpecificHeat.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setSpecificHeat(value) @pyqtSlot(bool) def slotThickness(self, checked): """ check box for Y Plus """ status = 'off' if checked: status = 'on' self.mdl.setThicknessStatus(status) if status == 'on': 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() @pyqtSlot(str) def slotThicknessValue(self, text): """ Update the thickness value """ if self.lineEditThickness.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setThicknessValue(value)
class TurboMachineryView(QWidget, Ui_TurboMachineryForm): """ """ def __init__(self, parent, case): """ Constructor. """ QWidget.__init__(self, parent) Ui_TurboMachineryForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = TurboMachineryModel(self.case) # Combo model self.modelTurboMachineryType = ComboModel(self.comboBoxTurboMachineryType, 3, 1) self.modelTurboMachineryType.addItem(self.tr("None"), "off") self.modelTurboMachineryType.addItem(self.tr("Full transient simulation"), "transient") self.modelTurboMachineryType.addItem(self.tr("Frozen rotor model"), "frozen") # Set up validators self.lineEditDX.setValidator(DoubleValidator(self.lineEditDX)) self.lineEditDY.setValidator(DoubleValidator(self.lineEditDY)) self.lineEditDZ.setValidator(DoubleValidator(self.lineEditDZ)) self.lineEditX1.setValidator(DoubleValidator(self.lineEditX1)) self.lineEditY1.setValidator(DoubleValidator(self.lineEditY1)) self.lineEditZ1.setValidator(DoubleValidator(self.lineEditZ1)) # tableView TurboMachinery self.rotorModel = StandardItemModelRotor(self.mdl) self.tableViewTurboMachinery.setModel(self.rotorModel) self.tableViewTurboMachinery.resizeColumnsToContents() self.tableViewTurboMachinery.resizeRowsToContents() self.tableViewTurboMachinery.setAlternatingRowColors(True) self.tableViewTurboMachinery.setSelectionBehavior(QAbstractItemView.SelectRows) delegateVelocity = VelocityDelegate(self.tableViewTurboMachinery) self.tableViewTurboMachinery.setItemDelegateForColumn(0, delegateVelocity) delegateSelector = LineEditDelegateSelector(self.tableViewTurboMachinery) self.tableViewTurboMachinery.setItemDelegateForColumn(1, delegateSelector) self.tableViewTurboMachinery.resizeColumnsToContents() self.tableViewTurboMachinery.resizeRowsToContents() self.tableViewTurboMachinery.horizontalHeader().setResizeMode(1,QHeaderView.Stretch) # Faces to join selection (Custom Widgets) model = StandardItemModelFaces(self, self.mdl, 'face_joining') self.widgetFacesJoin.modelFaces = model self.widgetFacesJoin.tableView.setModel(model) # Connections self.connect(self.comboBoxTurboMachineryType, SIGNAL("activated(const QString&)"), self.slotTurboModel) self.connect(self.rotorModel , SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), self.dataChanged) self.connect(self.tableViewTurboMachinery , SIGNAL("clicked(const QModelIndex &)"), self.slotChangeSelection) self.connect(self.pushButtonAdd, SIGNAL("clicked()"), self.slotAddRotor) self.connect(self.pushButtonDelete, SIGNAL("clicked()"), self.slotDeleteRotor) self.connect(self.lineEditDX, SIGNAL("textChanged(const QString &)"), self.slotRotationX) self.connect(self.lineEditDY, SIGNAL("textChanged(const QString &)"), self.slotRotationY) self.connect(self.lineEditDZ, SIGNAL("textChanged(const QString &)"), self.slotRotationZ) self.connect(self.lineEditX1, SIGNAL("textChanged(const QString &)"), self.slotCenterRotationX1) self.connect(self.lineEditY1, SIGNAL("textChanged(const QString &)"), self.slotCenterRotationY1) self.connect(self.lineEditZ1, SIGNAL("textChanged(const QString &)"), self.slotCenterRotationZ1) if self.mdl.getRotorList() != None: for i in range(len(self.mdl.getRotorList())): self.rotorModel.addItem(i) # Initialize widget self.updateView() self.case.undoStartGlobal() def __setValuesRotation(self): """ Put values found in xml file as soon as mode is "rotation" """ rotor_id = self.tableViewTurboMachinery.currentIndex().row() rx, ry, rz = self.mdl.getRotationDirection(rotor_id) px, py, pz = self.mdl.getRotationCenter(rotor_id) self.lineEditDX.setText(str(rx)) self.lineEditDY.setText(str(ry)) self.lineEditDZ.setText(str(rz)) self.lineEditX1.setText(str(px)) self.lineEditY1.setText(str(py)) self.lineEditZ1.setText(str(pz)) def updateView(self): """ Update view """ mdl = self.mdl.getTurboMachineryModel() self.modelTurboMachineryType.setItem(str_model = mdl) rotor_id = self.tableViewTurboMachinery.currentIndex().row() if mdl != "off": if len(self.mdl.getRotorList()) == 1: self.pushButtonDelete.setEnabled(False) else: self.pushButtonDelete.setEnabled(True) self.groupBoxDefineTurboMachinery.show() self.groupBoxJoin.show() self.groupBoxRotation.hide() if rotor_id != -1: self.groupBoxRotation.show() self.__setValuesRotation() if mdl == "frozen": self.groupBoxJoin.setTitle("Face joining (optionnal)") elif mdl == "transient": self.groupBoxJoin.setTitle("Face joining") else: self.groupBoxDefineTurboMachinery.hide() self.groupBoxRotation.hide() self.groupBoxJoin.hide() @pyqtSignature("const QModelIndex &, const QModelIndex &") def dataChanged(self, topLeft, bottomRight): self.tableViewTurboMachinery.resizeColumnsToContents() self.tableViewTurboMachinery.resizeRowsToContents() self.tableViewTurboMachinery.horizontalHeader().setResizeMode(1,QHeaderView.Stretch) self.updateView() @pyqtSignature("const QModelIndex &") def slotChangeSelection(self, text=None): """ detect change selection to update constant properties """ self.updateView() @pyqtSignature("const QString&") def slotTurboModel(self, text): """ Input turbomachinery model. """ for nb in range(self.rotorModel.rowCount()): self.rotorModel.delItem(0) mdl = self.modelTurboMachineryType.dicoV2M[str(text)] self.mdl.setTurboMachineryModel(mdl) if len(self.mdl.getRotorList()) > 0: for i in range(len(self.mdl.getRotorList())): self.rotorModel.addItem(i) self.updateView() @pyqtSignature("") def slotAddRotor(self): """ Add rotor """ self.mdl.addRotor() self.rotorModel.addItem(len(self.mdl.getRotorList()) -1) self.tableViewTurboMachinery.clearSelection() self.updateView() @pyqtSignature("") def slotDeleteRotor(self): """ Delete the selected rotor from the list """ rotor_id = self.tableViewTurboMachinery.currentIndex().row() self.mdl.delRotor(rotor_id) self.rotorModel.delItem(rotor_id) self.tableViewTurboMachinery.clearSelection() self.updateView() @pyqtSignature("const QString&") def slotRotationX(self, text): """ Periodicity rotation for X """ rotor_id = self.tableViewTurboMachinery.currentIndex().row() if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setRotationVector(rotor_id, "axis_x", val) @pyqtSignature("const QString&") def slotRotationY(self, text): """ Periodicity rotation for Y """ rotor_id = self.tableViewTurboMachinery.currentIndex().row() if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setRotationVector(rotor_id, "axis_y", val) @pyqtSignature("const QString&") def slotRotationZ(self, text): """ Periodicity rotation for Z """ rotor_id = self.tableViewTurboMachinery.currentIndex().row() if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setRotationVector(rotor_id, "axis_z", val) @pyqtSignature("const QString&") def slotCenterRotationX1(self, text): """ Periodicity : center of rotation """ rotor_id = self.tableViewTurboMachinery.currentIndex().row() if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setRotationCenter(rotor_id, "invariant_x", val) @pyqtSignature("const QString&") def slotCenterRotationY1(self, text): """ Periodicity : center of rotation """ rotor_id = self.tableViewTurboMachinery.currentIndex().row() if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setRotationCenter(rotor_id, "invariant_y", val) @pyqtSignature("const QString&") def slotCenterRotationZ1(self, text): """ Periodicity : center of rotation """ rotor_id = self.tableViewTurboMachinery.currentIndex().row() if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setRotationCenter(rotor_id, "invariant_z", val) def tr(self, text): """ Translation """ return text
class GasCombustionView(QWidget, Ui_GasCombustionForm): """ Class to open the Gas Combustion option Page. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_GasCombustionForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = GasCombustionModel(self.case) # Set models and number of elements for combo boxes self.modelGasCombustionOption = ComboModel(self.comboBoxGasCombustionOption,1,1) # Connections self.connect(self.comboBoxGasCombustionOption, SIGNAL("activated(const QString&)"), self.slotGasCombustionOption) self.connect(self.pushButtonThermochemistryData, SIGNAL("pressed()"), self.__slotSearchThermochemistryData) # Initialize Widgets model = self.mdl.getGasCombustionModel() if model == 'd3p': self.modelGasCombustionOption.addItem(self.tr("adiabatic model"), "adiabatic") self.modelGasCombustionOption.addItem(self.tr("non adiabatic model"), "extended") elif model == 'ebu': self.modelGasCombustionOption.addItem(self.tr("reference Spalding model"), "spalding") self.modelGasCombustionOption.addItem(self.tr("extended model with enthalpy source term"), "enthalpy_st") self.modelGasCombustionOption.addItem(self.tr("extended model with mixture fraction transport"), "mixture_st") self.modelGasCombustionOption.addItem(self.tr("extended model with enthalpy and mixture fraction transport"), "enthalpy_mixture_st") elif model == 'lwp': self.modelGasCombustionOption.addItem(self.tr("reference two-peak model with adiabatic condition"), "2-peak_adiabatic") self.modelGasCombustionOption.addItem(self.tr("reference two-peak model with enthalpy source term"), "2-peak_enthalpy") self.modelGasCombustionOption.addItem(self.tr("reference three-peak model with adiabatic condition"), "3-peak_adiabatic") self.modelGasCombustionOption.addItem(self.tr("reference three-peak model with enthalpy source term"), "3-peak_enthalpy") self.modelGasCombustionOption.addItem(self.tr("reference four-peak model with adiabatic condition"), "4-peak_adiabatic") self.modelGasCombustionOption.addItem(self.tr("reference four-peak model with enthalpy source term"), "4-peak_enthalpy") option = self.mdl.getGasCombustionOption() self.modelGasCombustionOption.setItem(str_model= option) name = self.mdl.getThermoChemistryDataFileName() if name != None: self.labelThermochemistryFile.setText(str(name)) setGreenColor(self.pushButtonThermochemistryData, False) else: setGreenColor(self.pushButtonThermochemistryData, True) self.case.undoStartGlobal() @pyqtSignature("const QString&") def slotGasCombustionOption(self, text): """ Private slot. Binding method for gas combustion models. """ option = self.modelGasCombustionOption.dicoV2M[str(text)] self.mdl.setGasCombustionOption(option) @pyqtSignature("") def __slotSearchThermochemistryData(self): """ Select a properties file of data for electric arc """ data = self.case['data_path'] title = self.tr("Thermochemistry file of data.") filetypes = self.tr("Thermochemistry (*dp_*);;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.labelThermochemistryFile.setText(str(file)) self.mdl.setThermoChemistryDataFileName(file) setGreenColor(self.pushButtonThermochemistryData, False) def tr(self, text): """ Translation """ return text
class DropletCondensationEvaporationView(QWidget, Ui_DropletCondensationEvaporation): """ Droplet Condensation-Evaporation model layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_DropletCondensationEvaporation.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = DropletCondensationEvaporationModel(self.case) 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("Droplets diameter"), "diameter") # Validators validatorYplus = DoubleValidator(self.lineEditYPlus, min=0.0) validatorYplus.setExclusiveMin(True) self.lineEditYPlus.setValidator(validatorYplus) # Connect signals to slots self.comboBoxYPlus.activated[str].connect(self.slotYPlus) self.lineEditYPlus.textChanged[str].connect(self.slotYPlusValue) 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.case.undoStartGlobal() @pyqtSlot(str) def slotYPlus(self, text): """ configure Y Plus model """ value = self.modelYPlus.dicoV2M[text] log.debug("slotYPlus -> %s" % value) self.mdl.setYPlusModel(value) if value == "Yplus_value": self.lineEditYPlus.show() self.lineEditYPlus.setText(str(self.mdl.getYPlusValue())) else: self.lineEditYPlus.hide() @pyqtSlot(str) def slotYPlusValue(self, text): """ Update the Yplus value """ if self.lineEditYPlus.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setYPlusValue(value)
class FluidCharacteristicsView(QWidget, Ui_FluidCharacteristicsForm): """ Class to open Molecular Properties Page. """ density = """# Density of air density = 1.293*(273.15 / temperature); # density for mixtures of gases # # Y1 -> mass fraction of component 1 # Y2 -> mass fraction of component 2 rho1 = 1.25051; rho2 = 1.7832; A = (Y1 / rho1) + (Y2 /rho2); density = 1.0 / A; """ density_h = """# Density density = enthalpy / 1040. * 1.29; # density for mixtures of gases # # Y1 -> mass fraction of component 1 # Y2 -> mass fraction of component 2 rho1 = 1.25051; rho2 = 1.7832; A = (Y1 / rho1) + (Y2 /rho2); density = 1.0 / A; """ molecular_viscosity="""# Sutherland's Formula # Gas Cst T0 mu0 # air 120 291.15 18.27e-6 # nitrogen 111 300.55 17.81e-6 # oxygen 127 292.25 20.18e-6 # carbon dioxide 240 293.15 14.8e-6 # carbon monoxide 118 288.15 17.2e-6 # hydrogen 72 293.85 8.76e-6 # ammonia 370 293.15 9.82e-6 # sulfur dioxide 416 293.65 12.54e-6 # helium 79.4 273 19e-6 CST = 120; T0 = 291.15; mu_ref = 18.27e-6; if ( temperature > 0 && temperature < 555) { molecular_viscosity = mu_ref * ((T0+CST) / (temperature+CST)) * (temperature/T0)^(3./2.); } else { molecular_viscosity = -999.0; } """ molecular_viscosity_h=""" CST = 120; T0 = 291.15; mu_ref = 18.27e-6; temperature = enthalpy / 1040.; if ( enthalpy > 0) { molecular_viscosity = mu_ref * (T0+CST / temperature+CST) * (temperature/T0)^(3./2.); } else { molecular_viscosity = -999.0; } """ specific_heat="""# specific heat for mixtures of gases # # Y1 -> mass fraction of component 1 # Y2 -> mass fraction of component 2 Cp1 = 520.3; Cp2 = 1040.0; specific_heat = Y1 * Cp1 + Y2 *Cp2; """ volume_viscosity="""# volume_viscosity """ thermal_conductivity="""# oxygen thermal_conductivity = 6.2e-5 * temperature + 8.1e-3; # nitrogen thermal_conductivity = 6.784141e-5 * temperature + 5.564317e-3; # hydrogen thermal_conductivity = 4.431e-4 * temperature + 5.334e-2; """ thermal_conductivity_h=""" temperature = enthalpy / 1040.; thermal_conductivity = 6.2e-5 * temperature + 8.1e-3; """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_FluidCharacteristicsForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = FluidCharacteristicsModel(self.case) if EOS == 1: self.ava = eosAva.EosAvailable() import cs_config cfg = cs_config.config() self.freesteam = 0 if cfg.libs['freesteam'].have != "no": self.freesteam = 1 if CompressibleModel(self.case).getCompressibleModel() != 'off': self.lst = [('density', 'Rho'), ('molecular_viscosity', 'Mu'), ('specific_heat', 'Cp'), ('thermal_conductivity', 'Al'), ('volume_viscosity', 'Viscv0'), ('dynamic_diffusion', 'Diftl0')] elif CoalCombustionModel(self.case).getCoalCombustionModel() != 'off' or \ GasCombustionModel(self.case).getGasCombustionModel() != 'off': self.lst = [('density', 'Rho'), ('molecular_viscosity', 'Mu'), ('specific_heat', 'Cp'), ('dynamic_diffusion', 'Diftl0')] else: self.lst = [('density', 'Rho'), ('molecular_viscosity', 'Mu'), ('specific_heat', 'Cp'), ('thermal_conductivity', 'Al')] self.list_scalars = [] self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "temperature_celsius": self.list_scalars.append((s, self.tr("Thermal scalar: temperature (C)"))) elif mdl == "temperature_kelvin": self.list_scalars.append((s, self.tr("Thermal scalar: temperature (K)"))) elif mdl != "off": self.list_scalars.append((s, self.tr("Thermal scalar"))) self.m_sca = DefineUserScalarsModel(self.case) for s in self.m_sca.getUserScalarNameList(): self.list_scalars.append((s, self.tr("Additional scalar"))) # Particular Widget initialization taking into account of "Calculation Features" mdl_atmo, mdl_joule, mdl_thermal, mdl_gas, mdl_coal, mdl_comp = self.mdl.getThermoPhysicalModel() # Combo models self.modelRho = ComboModel(self.comboBoxRho, 3, 1) self.modelMu = ComboModel(self.comboBoxMu, 3, 1) self.modelCp = ComboModel(self.comboBoxCp, 3, 1) self.modelAl = ComboModel(self.comboBoxAl, 3, 1) self.modelDiff = ComboModel(self.comboBoxDiff, 2, 1) self.modelNameDiff = ComboModel(self.comboBoxNameDiff,1,1) self.modelViscv0 = ComboModel(self.comboBoxViscv0, 3, 1) self.modelDiftl0 = ComboModel(self.comboBoxDiftl0, 3, 1) self.modelMaterial = ComboModel(self.comboBoxMaterial, 1, 1) self.modelMethod = ComboModel(self.comboBoxMethod, 1, 1) self.modelPhas = ComboModel(self.comboBoxPhas, 2, 1) self.modelRho.addItem(self.tr('constant'), 'constant') self.modelRho.addItem(self.tr('variable'), 'variable') self.modelRho.addItem(self.tr('thermal law'), 'thermal_law') if mdl_atmo != 'off': self.modelRho.addItem(self.tr('defined in atphyv'), 'variable') elif mdl_joule == 'arc': self.modelRho.addItem(self.tr('defined in elphyv'), 'variable') self.modelMu.addItem(self.tr('constant'), 'constant') self.modelMu.addItem(self.tr('variable'), 'variable') self.modelMu.addItem(self.tr('thermal law'), 'thermal_law') if mdl_joule == 'arc': self.modelMu.addItem(self.tr('defined in elphyv'), 'variable') self.modelCp.addItem(self.tr('constant'), 'constant') self.modelCp.addItem(self.tr('variable'), 'variable') self.modelCp.addItem(self.tr('thermal law'), 'thermal_law') if mdl_joule == 'arc': self.modelCp.addItem(self.tr('defined in elphyv'), 'variable') self.modelAl.addItem(self.tr('constant'), 'constant') self.modelAl.addItem(self.tr('variable'), 'variable') self.modelAl.addItem(self.tr('thermal law'), 'thermal_law') if mdl_joule == 'arc': self.modelAl.addItem(self.tr('defined in elphyv'), 'variable') self.modelDiff.addItem(self.tr('constant'), 'constant') self.modelDiff.addItem(self.tr('variable'), 'variable') self.modelViscv0.addItem(self.tr('constant'), 'constant') self.modelViscv0.addItem(self.tr('variable'), 'variable') self.modelViscv0.addItem(self.tr('thermal law'), 'thermal_law') self.modelDiftl0.addItem(self.tr('constant'), 'constant') self.modelDiftl0.addItem(self.tr('variable'), 'variable') self.modelDiftl0.addItem(self.tr('thermal law'), 'thermal_law') self.modelPhas.addItem(self.tr('liquid'), 'liquid') self.modelPhas.addItem(self.tr('gas'), 'gas') if (self.freesteam == 0 and EOS == 0) or \ self.m_th.getThermalScalarModel() == "off" or \ mdl_joule != 'off' or mdl_comp != 'off': self.groupBoxTableChoice.hide() else: self.groupBoxTableChoice.show() self.lineEditReference.setEnabled(False) # suppress perfect gas self.modelMaterial.addItem(self.tr('user material'), 'user_material') tmp = ["Argon", "Nitrogen", "Hydrogen", "Oxygen", "Helium", "Air"] if EOS == 1: fls = self.ava.whichFluids() for fli in fls: if fli not in tmp: tmp.append(fli) self.modelMaterial.addItem(self.tr(fli), fli) if self.freesteam == 1 and EOS == 0: self.modelMaterial.addItem(self.tr('Water'), 'Water') material = self.mdl.getMaterials() self.modelMaterial.setItem(str_model=material) self.updateMethod() self.scalar = "" scalar_list = self.m_sca.getUserScalarNameList() for s in self.m_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for scalar in scalar_list: self.modelNameDiff.addItem(scalar) # Connections self.connect(self.comboBoxRho, SIGNAL("activated(const QString&)"), self.slotStateRho) self.connect(self.comboBoxMu, SIGNAL("activated(const QString&)"), self.slotStateMu) self.connect(self.comboBoxCp, SIGNAL("activated(const QString&)"), self.slotStateCp) self.connect(self.comboBoxAl, SIGNAL("activated(const QString&)"), self.slotStateAl) self.connect(self.comboBoxDiff, SIGNAL("activated(const QString&)"), self.slotStateDiff) self.connect(self.comboBoxNameDiff, SIGNAL("activated(const QString&)"), self.slotNameDiff) self.connect(self.comboBoxViscv0, SIGNAL("activated(const QString&)"), self.slotStateViscv0) self.connect(self.comboBoxMaterial, SIGNAL("activated(const QString&)"), self.slotMaterial) self.connect(self.comboBoxMethod, SIGNAL("activated(const QString&)"), self.slotMethod) self.connect(self.comboBoxPhas, SIGNAL("activated(const QString&)"), self.slotPhas) self.connect(self.lineEditRho, SIGNAL("textChanged(const QString &)"), self.slotRho) self.connect(self.lineEditMu, SIGNAL("textChanged(const QString &)"), self.slotMu) self.connect(self.lineEditCp, SIGNAL("textChanged(const QString &)"), self.slotCp) self.connect(self.lineEditAl, SIGNAL("textChanged(const QString &)"), self.slotAl) self.connect(self.lineEditDiff, SIGNAL("textChanged(const QString &)"), self.slotDiff) self.connect(self.lineEditDiftl0, SIGNAL("textChanged(const QString &)"), self.slotDiftl0) self.connect(self.lineEditViscv0, SIGNAL("textChanged(const QString &)"), self.slotViscv0) self.connect(self.pushButtonRho, SIGNAL("clicked()"), self.slotFormulaRho) self.connect(self.pushButtonMu, SIGNAL("clicked()"), self.slotFormulaMu) self.connect(self.pushButtonCp, SIGNAL("clicked()"), self.slotFormulaCp) self.connect(self.pushButtonAl, SIGNAL("clicked()"), self.slotFormulaAl) self.connect(self.pushButtonDiff, SIGNAL("clicked()"), self.slotFormulaDiff) self.connect(self.pushButtonViscv0, SIGNAL("clicked()"), self.slotFormulaViscv0) # Validators validatorRho = DoubleValidator(self.lineEditRho, min = 0.0) validatorMu = DoubleValidator(self.lineEditMu, min = 0.0) validatorCp = DoubleValidator(self.lineEditCp, min = 0.0) validatorAl = DoubleValidator(self.lineEditAl, min = 0.0) validatorDiff = DoubleValidator(self.lineEditDiff, min = 0.0) validatorViscv0 = DoubleValidator(self.lineEditViscv0, min = 0.0) validatorDiftl0 = DoubleValidator(self.lineEditDiftl0, min = 0.0) validatorRho.setExclusiveMin(True) validatorMu.setExclusiveMin(True) validatorCp.setExclusiveMin(True) validatorAl.setExclusiveMin(True) validatorDiff.setExclusiveMin(True) validatorDiftl0.setExclusiveMin(True) self.lineEditRho.setValidator(validatorRho) self.lineEditMu.setValidator(validatorMu) self.lineEditCp.setValidator(validatorCp) self.lineEditAl.setValidator(validatorAl) self.lineEditDiff.setValidator(validatorDiff) self.lineEditViscv0.setValidator(validatorViscv0) self.lineEditDiftl0.setValidator(validatorDiftl0) if scalar_list == []: self.groupBoxDiff.hide() else : self.groupBoxDiff.show() self.lineEditDiff.setText(str(self.m_sca.getScalarDiffusivityInitialValue(self.scalar))) diff_choice = self.m_sca.getScalarDiffusivityChoice(self.scalar) self.modelDiff.setItem(str_model=diff_choice) self.modelNameDiff.setItem(str_model=str(self.scalar)) if diff_choice != 'variable': self.pushButtonDiff.setEnabled(False) setGreenColor(self.pushButtonDiff, False) else: self.pushButtonDiff.setEnabled(True) setGreenColor(self.pushButtonDiff, True) #compressible self.groupBoxViscv0.hide() # combustion self.groupBoxDiftl0.hide() # Standard Widget initialization for tag, symbol in self.lst: __model = getattr(self, "model" + symbol) __line = getattr(self, "lineEdit" + symbol) __button = getattr(self, "pushButton" + symbol) __label = getattr(self, "label" + symbol) __labelu = getattr(self, "labelUnit" + symbol) if tag != 'dynamic_diffusion': __labelv = getattr(self, "labelVar" + symbol) c = self.mdl.getPropertyMode(tag) __model.setItem(str_model=c) if c == 'variable': __button.setEnabled(True) __label.setText(self.tr("Reference value")) else: __button.setEnabled(False) __label.setText(self.tr("Reference value")) if c == 'thermal_law': __line.hide() __label.hide() __labelu.hide() __labelv.hide() else: __line.show() __label.show() __labelu.show() __labelv.show() if self.mdl.getMaterials() == "user_material": __model.disableItem(str_model='thermal_law') else: __model.enableItem(str_model='thermal_law') else: __label.setText(self.tr("Reference value")) self.mdl.getInitialValue(tag) __line.setText(str(self.mdl.getInitialValue(tag))) # no 'thermal_conductivity' if not Joule and not Thermal scalar and not if mdl_joule == 'off' and mdl_thermal == 'off' and mdl_atmo == 'off' and\ CompressibleModel(self.case).getCompressibleModel() == 'off': self.groupBoxAl.hide() if mdl_gas != 'off' or mdl_coal != 'off': self.groupBoxDiftl0.show() for tag, symbol in self.lst: __model = getattr(self, "model" + symbol) __line = getattr(self, "lineEdit" + symbol) __button = getattr(self, "pushButton" + symbol) __label = getattr(self, "label" + symbol) __combo = getattr(self, "comboBox" + symbol) # Gas or coal combustion if mdl_gas != 'off' or mdl_coal != 'off': if tag == 'density': __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) self.mdl.setPropertyMode(tag, 'variable') __label.setText(self.tr("Calculation by\n perfect gas law")) __line.setText(str("")) __line.setEnabled(False) elif tag == 'dynamic_diffusion': __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) else: __model.setItem(str_model='constant') self.mdl.setPropertyMode(tag, 'constant') # Joule if mdl_joule == 'arc': __model.disableItem(str_model='constant') __model.disableItem(str_model='variable') __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) self.mdl.setPropertyMode(tag, 'variable') if mdl_joule == 'joule': __model.setItem(str_model='variable') __model.disableItem(str_model='constant') self.mdl.setPropertyMode(tag, 'variable') # Atmospheric Flows if mdl_atmo != 'off': if tag == 'density': __model.disableItem(str_model='constant') __model.disableItem(str_model='variable') __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) # Compressible Flows if mdl_comp != 'off': if tag == 'density': __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) __combo.hide() __button.hide() self.mdl.setPropertyMode(tag, 'variable') __line.setEnabled(True) self.groupBoxViscv0.hide() if tag == 'specific_heat': __model.setItem(str_model='constant') __combo.setEnabled(False) __button.setEnabled(False) self.mdl.setPropertyMode(tag, 'constant') self.groupBoxCp.setTitle('Isobaric specific heat') if tag == 'volume_viscosity': __combo.setEnabled(True) c = self.mdl.getPropertyMode(tag) if c == 'variable': __button.setEnabled(True) else: __button.setEnabled(False) self.groupBoxViscv0.show() else: if tag == 'specific_heat': self.groupBoxCp.setTitle('Specific heat') self.case.undoStartGlobal() def updateTypeChoice(self): """ add/suppress thermo tables for each proprties """ for tag, symbol in self.lst: __model = getattr(self, "model" + symbol) if self.mdl.getMaterials() == "user_material": __model.disableItem(str_model='thermal_law') else: __model.enableItem(str_model='thermal_law') c = self.mdl.getPropertyMode(tag) __model.setItem(str_model=c) def updateMethod(self): """ update method list with material choice """ for nb in range(len(self.modelMethod.getItems())): self.modelMethod.delItem(0) self.comboBoxPhas.hide() self.labelPhas.hide() if self.mdl.getMaterials() == "user_material": self.modelMethod.addItem(self.tr('user properties'), 'user_properties') else : if EOS == 1: material = self.mdl.getMaterials() self.ava.setMethods(material) fls = self.ava.whichMethods() for fli in fls: self.modelMethod.addItem(self.tr(fli),fli) if self.mdl.getMethod() != "freesteam": self.comboBoxPhas.show() self.labelPhas.show() if self.freesteam == 1 and self.mdl.getMaterials() == "Water": self.modelMethod.addItem(self.tr("freesteam"), "freesteam") # update comboBoxMethod method = self.mdl.getMethod() self.modelMethod.setItem(str_model=method) self.updateReference() def updateReference(self): """ update Reference with material, method and field nature choice """ # update lineEditReference self.lineEditReference.setText(self.mdl.getReference()) @pyqtSignature("const QString &") def slotMaterial(self, text): """ Method to call 'setMaterial' """ choice = self.modelMaterial.dicoV2M[str(text)] self.mdl.setMaterials(choice) self.updateMethod() self.updateTypeChoice() @pyqtSignature("const QString &") def slotPhas(self, text): """ Method to call 'setFieldNature' """ choice = self.modelPhas.dicoV2M[str(text)] self.mdl.setFieldNature(choice) self.updateReference() @pyqtSignature("const QString &") def slotMethod(self, text): """ Method to call 'setMethod' """ choice = self.modelMethod.dicoV2M[str(text)] self.mdl.setMethod(choice) self.comboBoxPhas.hide() self.labelPhas.hide() if self.mdl.getMaterials() != "user_material" and \ self.mdl.getMethod() != "freesteam": self.comboBoxPhas.show() self.labelPhas.show() self.updateReference() @pyqtSignature("const QString &") def slotStateRho(self, text): """ Method to call 'getState' with correct arguements for 'rho' """ self.__changeChoice(str(text), 'Rho', 'density') @pyqtSignature("const QString &") def slotStateMu(self, text): """ Method to call 'getState' with correct arguements for 'Mu' """ self.__changeChoice(str(text), 'Mu', 'molecular_viscosity') @pyqtSignature("const QString &") def slotStateCp(self, text): """ Method to call 'getState' with correct arguements for 'Cp' """ self.__changeChoice(str(text), 'Cp', 'specific_heat') @pyqtSignature("const QString &") def slotStateViscv0(self, text): """ Method to call 'getState' with correct arguements for 'Viscv0' """ self.__changeChoice(str(text), 'Viscv0', 'volume_viscosity') @pyqtSignature("const QString &") def slotStateAl(self, text): """ Method to call 'getState' with correct arguements for 'Al' """ self.__changeChoice(str(text), 'Al', 'thermal_conductivity') @pyqtSignature("const QString &") def slotStateDiff(self, text): """ Method to set diffusion choice for the coefficient """ choice = self.modelDiff.dicoV2M[str(text)] log.debug("slotStateDiff -> %s" % (text)) if choice != 'variable': self.pushButtonDiff.setEnabled(False) setGreenColor(self.pushButtonDiff, False) else: self.pushButtonDiff.setEnabled(True) setGreenColor(self.pushButtonDiff, True) self.m_sca.setScalarDiffusivityChoice(self.scalar, choice) @pyqtSignature("const QString &") def slotNameDiff(self, text): """ Method to set the variance scalar choosed """ choice = self.modelNameDiff.dicoV2M[str(text)] log.debug("slotStateDiff -> %s" % (text)) self.scalar = str(text) self.lineEditDiff.setText(str(self.m_sca.getScalarDiffusivityInitialValue(self.scalar))) mdl = self.m_sca.getScalarDiffusivityChoice(self.scalar) self.modelDiff.setItem(str_model=mdl) if mdl!= 'variable': self.pushButtonDiff.setEnabled(False) setGreenColor(self.pushButtonDiff, False) else: self.pushButtonDiff.setEnabled(True) setGreenColor(self.pushButtonDiff, True) def __changeChoice(self, text, sym, tag): """ Input variable state """ __model = getattr(self, "model" + sym) __line = getattr(self, "lineEdit" + sym) __combo = getattr(self, "comboBox" + sym) __label = getattr(self, "label" + sym) __button = getattr(self, "pushButton" + sym) __labelu = getattr(self, "labelUnit" + sym) __labelv = getattr(self, "labelVar" + sym) choice = __model.dicoV2M[text] log.debug("__changeChoice -> %s, %s" % (text, choice)) if choice != 'variable': __button.setEnabled(False) setGreenColor(__button, False) else: __button.setEnabled(True) setGreenColor(__button, True) if choice == 'thermal_law': __line.hide() __label.hide() __labelu.hide() __labelv.hide() else: __line.show() __label.show() __labelu.show() __labelv.show() self.mdl.setPropertyMode(tag, choice) @pyqtSignature("const QString &") def slotRho(self, text): """ Update the density """ if self.sender().validator().state == QValidator.Acceptable: rho = from_qvariant(text, float) self.mdl.setInitialValueDensity(rho) @pyqtSignature("const QString &") def slotMu(self, text): """ Update the molecular viscosity """ if self.sender().validator().state == QValidator.Acceptable: mu = from_qvariant(text, float) self.mdl.setInitialValueViscosity(mu) @pyqtSignature("const QString &") def slotCp(self, text): """ Update the specific heat """ if self.sender().validator().state == QValidator.Acceptable: cp = from_qvariant(text, float) self.mdl.setInitialValueHeat(cp) @pyqtSignature("const QString &") def slotViscv0(self, text): """ Update the volumic viscosity """ if self.sender().validator().state == QValidator.Acceptable: viscv0 = from_qvariant(text, float) self.mdl.setInitialValueVolumicViscosity(viscv0) @pyqtSignature("const QString &") def slotAl(self, text): """ Update the thermal conductivity """ if self.sender().validator().state == QValidator.Acceptable: al = from_qvariant(text, float) self.mdl.setInitialValueCond(al) @pyqtSignature("const QString &") def slotDiftl0(self, text): """ Update the thermal conductivity """ if self.sender().validator().state == QValidator.Acceptable: diftl0 = from_qvariant(text, float) self.mdl.setInitialValueDyn(diftl0) @pyqtSignature("const QString &") def slotDiff(self, text): """ Update the thermal conductivity """ if self.sender().validator().state == QValidator.Acceptable: diff = from_qvariant(text, float) self.m_sca.setScalarDiffusivityInitialValue(self.scalar, diff) @pyqtSignature("") def slotFormulaRho(self): """ User formula for density """ exp = self.mdl.getFormula('density') req = [('density', 'Density')] self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "temperature_celsius": TempInContext = "("+s+" + 273.15)" exa = FluidCharacteristicsView.density.replace("temperature", TempInContext) elif mdl == "enthalpy": exa = FluidCharacteristicsView.density_h else: exa = FluidCharacteristicsView.density symbols_rho = [] for s in self.list_scalars: symbols_rho.append(s) rho0_value = self.mdl.getInitialValueDensity() ref_pressure = ReferenceValuesModel(self.case).getPressure() symbols_rho.append(('rho0', 'Density (reference value) = ' + str(rho0_value))) symbols_rho.append(('p0', 'Reference pressure = ' + str(ref_pressure))) dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = symbols_rho, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaRho -> %s" % str(result)) self.mdl.setFormula('density', result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotFormulaMu(self): """ User formula for molecular viscosity """ exp = self.mdl.getFormula('molecular_viscosity') req = [('molecular_viscosity', 'Molecular Viscosity')] self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "temperature_celsius": TempInContext = "("+s+" + 273.15)" exa = FluidCharacteristicsView.molecular_viscosity.replace("temperature", TempInContext) elif mdl == "enthalpy": exa = FluidCharacteristicsView.molecular_viscosity_h else: exa = FluidCharacteristicsView.molecular_viscosity symbols_mu = [] for s in self.list_scalars: symbols_mu.append(s) mu0_value = self.mdl.getInitialValueViscosity() rho0_value = self.mdl.getInitialValueDensity() ref_pressure = ReferenceValuesModel(self.case).getPressure() symbols_mu.append(('mu0', 'Viscosity (reference value) = ' + str(mu0_value))) symbols_mu.append(('rho0', 'Density (reference value) = ' + str(rho0_value))) symbols_mu.append(('p0', 'Reference pressure = ' + str(ref_pressure))) symbols_mu.append(('rho', 'Density')) if CompressibleModel(self.case).getCompressibleModel() == 'on': symbols_mu.append(('T', 'Temperature')) ref_temperature = ReferenceValuesModel(self.case).getTemperature() symbols_mu.append(('t0', 'Reference temperature = '+str(ref_temperature)+' K')) dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = symbols_mu, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMu -> %s" % str(result)) self.mdl.setFormula('molecular_viscosity', result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotFormulaCp(self): """ User formula for specific heat """ exp = self.mdl.getFormula('specific_heat') req = [('specific_heat', 'Specific heat')] exa = FluidCharacteristicsView.specific_heat symbols_cp = [] for s in self.list_scalars: symbols_cp.append(s) cp0_value = self.mdl.getInitialValueHeat() ref_pressure = ReferenceValuesModel(self.case).getPressure() symbols_cp.append(('cp0', 'Specific heat (reference value) = ' + str(cp0_value))) symbols_cp.append(('p0', 'Reference pressure = ' + str(ref_pressure))) dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = symbols_cp, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaRho -> %s" % str(result)) self.mdl.setFormula('specific_heat', result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotFormulaViscv0(self): """ User formula for volumic viscosity """ exp = self.mdl.getFormula('volume_viscosity') req = [('volume_viscosity', 'Volumic viscosity')] exa = FluidCharacteristicsView.volume_viscosity symbols_viscv0 = [] for s in self.list_scalars: symbols_viscv0.append(s) viscv0_value = self.mdl.getInitialValueVolumicViscosity() ref_pressure = ReferenceValuesModel(self.case).getPressure() ref_temperature = ReferenceValuesModel(self.case).getTemperature() symbols_viscv0.append(('viscv0', 'Volumic viscosity (reference value) = '+str(viscv0_value)+' J/kg/K')) symbols_viscv0.append(('p0', 'Reference pressure = '+str(ref_pressure)+' Pa')) symbols_viscv0.append(('t0', 'Reference temperature = '+str(ref_temperature)+' K')) symbols_viscv0.append(('T', 'Temperature')) dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = symbols_viscv0, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaViscv0 -> %s" % str(result)) self.mdl.setFormula('volume_viscosity', result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotFormulaAl(self): """ User formula for thermal conductivity """ exp = self.mdl.getFormula('thermal_conductivity') req = [('thermal_conductivity', 'Thermal conductivity')] self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "temperature_celsius": TempInContext = "("+s+" + 273.15)" exa = FluidCharacteristicsView.thermal_conductivity.replace("temperature", TempInContext) elif mdl == "enthalpy": exa = FluidCharacteristicsView.thermal_conductivity_h else: exa = FluidCharacteristicsView.thermal_conductivity symbols_al = [] for s in self.list_scalars: symbols_al.append(s) lambda0_value = self.mdl.getInitialValueCond() ref_pressure = ReferenceValuesModel(self.case).getPressure() symbols_al.append(('lambda0', 'Thermal conductivity (reference value) = ' + str(lambda0_value))) symbols_al.append(('p0', 'Reference pressure = ' + str(ref_pressure))) dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = symbols_al, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaAl -> %s" % str(result)) self.mdl.setFormula('thermal_conductivity', result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotFormulaDiff(self): """ User formula for the diffusion coefficient """ name = self.m_sca.getScalarDiffusivityName(self.scalar) exp = self.m_sca.getDiffFormula(self.scalar) req = [(str(name), str(self.scalar)+'diffusion coefficient')] exa = '' sym = [('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'),] sym.append((str(self.scalar),str(self.scalar))) diff0_value = self.m_sca.getScalarDiffusivityInitialValue(self.scalar) sym.append((str(name)+'_ref', str(self.scalar)+' diffusion coefficient (reference value) = '+str(diff0_value)+' m^2/s')) 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("slotFormulaDiff -> %s" % str(result)) self.m_sca.setDiffFormula(self.scalar, result) setGreenColor(self.pushButtonDiff, False) def tr(self, text): """ Translation """ return text
class ThermalRadiationAdvancedDialogView(QDialog, Ui_ThermalRadiationAdvancedDialogForm): """ Building of popup window for advanced options. """ def __init__(self, parent, case, default): """ Constructor """ QDialog.__init__(self, parent) Ui_ThermalRadiationAdvancedDialogForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.setWindowTitle(self.tr("Advanced options")) self.default = default self.result = self.default.copy() # Combo models self.modelTSRay = ComboModel(self.comboBoxTSRay, 3, 1) self.modelPrintT = ComboModel(self.comboBoxPrintT, 3, 1) self.modelPrintL = ComboModel(self.comboBoxPrintL, 3, 1) self.modelTSRay.addItem('0', '0') self.modelTSRay.addItem('1', '1') self.modelTSRay.addItem('2', '2') self.modelPrintT.addItem('0', '0') self.modelPrintT.addItem('1', '1') self.modelPrintT.addItem('2', '2') self.modelPrintL.addItem('0', '0') self.modelPrintL.addItem('1', '1') self.modelPrintL.addItem('2', '2') self.frequ = self.default['frequency'] self.tsr = self.default['idiver'] self.printTemp = self.default['tempP'] self.printLum = self.default['intensity'] model = self.default['model'] # Initialization self.lineEditFreq.setText(str(self.frequ)) self.modelTSRay.setItem(str_model=str(self.tsr)) self.modelPrintT.setItem(str_model=str(self.printTemp)) self.modelPrintL.setItem(str_model=str(self.printLum)) if model == 'dom': self.labelPrintL.show() self.comboBoxPrintL.show() else: self.labelPrintL.hide() self.comboBoxPrintL.hide() # Validator validatorFreq = IntValidator(self.lineEditFreq, min=1) self.lineEditFreq.setValidator(validatorFreq) self.case.undoStartGlobal() def accept(self): """ What to do when user clicks on 'OK'. """ if self.lineEditFreq.validator().state == QValidator.Acceptable: self.result['frequency'] = from_qvariant(self.lineEditFreq.text(), int) self.result['idiver'] = from_qvariant(self.comboBoxTSRay.currentText(), int) self.result['tempP'] = from_qvariant(self.comboBoxPrintT.currentText(), int) self.result['intensity'] = from_qvariant(self.comboBoxPrintL.currentText(), int) QDialog.accept(self) def reject(self): """ Method called when 'Cancel' button is clicked. """ QDialog.reject(self) def get_result(self): """ Method to get the result. """ return self.result 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 PerformanceTuningView(QWidget, Ui_PerformanceTuningForm): """ This page is devoted to the performance tuning control. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_PerformanceTuningForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = PerformanceTuningModel(self.case) # Combo models and items self.modelPartType = ComboModel(self.comboBox_PartType, 4, 1) self.modelPartOut = ComboModel(self.comboBox_PartOutput, 3, 1) self.modelPartType.addItem(self.tr("Default"), 'default') self.modelPartType.addItem(self.tr("PT-SCOTCH / SCOTCH"), 'scotch') self.modelPartType.addItem(self.tr("ParMETIS / METIS"), 'metis') self.modelPartType.addItem(self.tr("Morton curve (bounding box)"), 'morton sfc') self.modelPartType.addItem(self.tr("Morton curve (bounding cube)"), 'morton sfc cube') self.modelPartType.addItem(self.tr("Hilbert curve (bounding box)"), 'hilbert sfc') self.modelPartType.addItem(self.tr("Hilbert curve (bounding cube)"), 'hilbert sfc cube') self.modelPartType.addItem(self.tr("Block (unoptimized)"), 'block') import cs_config cfg = cs_config.config() if cfg.libs['scotch'].have == "no": self.comboBox_PartType.setItemData(1, QColor(Qt.red), Qt.TextColorRole) if cfg.libs['metis'].have == "no": self.comboBox_PartType.setItemData(2, QColor(Qt.red), Qt.TextColorRole) self.modelPartOut.addItem(self.tr("No"), 'no') self.modelPartOut.addItem(self.tr("For graph-based partitioning"), 'default') self.modelPartOut.addItem(self.tr("Yes"), 'yes') self.modelBlockIORead = ComboModel(self.comboBox_IORead, 6, 1) self.modelBlockIOWrite = ComboModel(self.comboBox_IOWrite, 4, 1) self.modelBlockIORead.addItem(self.tr("Default"), 'default') self.modelBlockIORead.addItem(self.tr("Standard I/O, serial"), 'stdio serial') self.modelBlockIORead.addItem(self.tr("Standard I/O, parallel"), 'stdio parallel') self.modelBlockIORead.addItem(self.tr("MPI I/O, independent"), 'mpi independent') self.modelBlockIORead.addItem(self.tr("MPI I/O, non-collective"), 'mpi noncollective') self.modelBlockIORead.addItem(self.tr("MPI I/O, collective"), 'mpi collective') self.modelBlockIOWrite.addItem(self.tr("Default"), 'default') self.modelBlockIOWrite.addItem(self.tr("Standard I/O, serial"), 'stdio serial') self.modelBlockIOWrite.addItem(self.tr("MPI I/O, non-collective"), 'mpi noncollective') self.modelBlockIOWrite.addItem(self.tr("MPI I/O, collective"), 'mpi collective') # Validators partListVd = RegExpValidator(self.lineEdit_PartList, QRegExp("[0-9- ]*")) self.lineEdit_PartList.setValidator(partListVd) # Connections self.radioButtonYes.clicked.connect(self.slotPartition) self.radioButtonNo.clicked.connect(self.slotPartition) self.toolButton_PartInputDir.pressed.connect( self.slotSearchPartInputDirectory) self.comboBox_PartOutput.activated[str].connect(self.slotPartOut) self.comboBox_PartType.activated[str].connect(self.slotPartType) self.lineEdit_PartList.textChanged[str].connect(self.slotPartitionList) self.spinBoxRankStep.valueChanged[int].connect(self.slotRankStep) self.checkBox_IgnorePerio.clicked[bool].connect(self.slotIgnorePerio) self.comboBox_IORead.activated[str].connect(self.slotBlockIOReadMethod) self.comboBox_IOWrite.activated[str].connect( self.slotBlockIOWriteMethod) self.spinBoxIORankStep.valueChanged[int].connect( self.slotBlockIORankStep) self.spinBoxIOMinBlockSize.valueChanged[int].connect( self.slotBlockIOMinSize) self.tabWidget.currentChanged[int].connect(self.slotchanged) # Widget initialization self.partinput_path = self.mdl.getPartitionInputPath() if self.partinput_path: if not os.path.isdir( os.path.join(self.case['case_path'], self.partinput_path)): title = self.tr("WARNING") msg = self.tr("Invalid path in %s!" % self.partinput_path) QMessageBox.warning(self, title, msg) self.radioButtonYes.setChecked(True) self.radioButtonNo.setChecked(False) else:
class LagrangianBoundariesView(QWidget, Ui_LagrangianBoundariesForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianBoundariesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = LagrangianBoundariesModel(self.case) self.modelBoundaries = StandardItemModelBoundaries(self.case, self.model) self.tableViewBoundaries.setModel(self.modelBoundaries) self.tableViewBoundaries.setAlternatingRowColors(True) self.tableViewBoundaries.horizontalHeader().setResizeMode(QHeaderView.Stretch) delegateInteraction = ParticleBoundaryInteractionDelegate(self.tableViewBoundaries) delegateClassNumber = ValueDelegate(self.tableViewBoundaries) self.tableViewBoundaries.setItemDelegateForColumn(2,delegateInteraction) self.tableViewBoundaries.setItemDelegateForColumn(3,delegateClassNumber) self.modelIPOIT = ComboModel(self.comboBoxIPOIT,3,1) self.modelIPOIT.addItem(self.tr("Volumic flow rate"), "rate") self.modelIPOIT.addItem(self.tr("Statistical weight set by values"), "prescribed") self.modelIPOIT.addItem(self.tr("User defined statistical weight"), "subroutine") self.modelIJUVW = ComboModel(self.comboBoxIJUVW,4,1) self.modelIJUVW.addItem(self.tr("Fluid velocity"), "fluid") self.modelIJUVW.addItem(self.tr("Normal direction velocity"), "norm") self.modelIJUVW.addItem(self.tr("Velocity given by values"), "components") self.modelIJUVW.addItem(self.tr("User defined velocity"), "subroutine") self.modelIJRTP = ComboModel(self.comboBoxIJRTP,2,1) self.modelIJRTP.addItem(self.tr("Temperature set by values"), "prescribed") self.modelIJRTP.addItem(self.tr("User defined temperature"), "subroutine") self.modelIJRDP = ComboModel(self.comboBoxIJRDP,2,1) self.modelIJRDP.addItem(self.tr("Diameter set by values"), "prescribed") self.modelIJRDP.addItem(self.tr("User defined diameter"), "subroutine") self.modelIRAWCL = ComboModel(self.comboBoxIRAWCL,2,1) self.modelIRAWCL.addItem(self.tr("Raw coal"), "raw_coal_as_received") self.modelIRAWCL.addItem(self.tr("User defined"), "subroutine") self.connect(self.tableViewBoundaries, SIGNAL("clicked(const QModelIndex &)"), self.slotSelectBoundary) self.connect(self.modelBoundaries, SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), self.dataChanged) self.connect(self.spinBoxICLAS, SIGNAL("valueChanged(int)"), self.slotICLAS) self.connect(self.lineEditIJNBP, SIGNAL("textChanged(const QString &)"), self.slotIJNBP) self.connect(self.lineEditIJFRE, SIGNAL("textChanged(const QString &)"), self.slotIJFRE) self.connect(self.lineEditICLST, SIGNAL("textChanged(const QString &)"), self.slotICLST) self.connect(self.lineEditIDEBT, SIGNAL("textChanged(const QString &)"), self.slotIDEBT) self.connect(self.comboBoxIPOIT, SIGNAL("activated(const QString&)"), self.slotIPOITChoice) self.connect(self.lineEditIPOIT, SIGNAL("textChanged(const QString &)"), self.slotIPOIT) self.connect(self.lineEditIROPT, SIGNAL("textChanged(const QString &)"), self.slotIROPT) self.connect(self.comboBoxIJUVW, SIGNAL("activated(const QString&)"), self.slotIJUVW) self.connect(self.lineEditIUNO, SIGNAL("textChanged(const QString &)"), self.slotIUNO) self.connect(self.lineEditIUPT, SIGNAL("textChanged(const QString &)"), self.slotIUPT) self.connect(self.lineEditIVPT, SIGNAL("textChanged(const QString &)"), self.slotIVPT) self.connect(self.lineEditIWPT, SIGNAL("textChanged(const QString &)"), self.slotIWPT) self.connect(self.comboBoxIJRTP, SIGNAL("activated(const QString&)"), self.slotIJRTP) self.connect(self.lineEditITPT, SIGNAL("textChanged(const QString &)"), self.slotITPT) self.connect(self.lineEditICPT, SIGNAL("textChanged(const QString &)"), self.slotICPT) self.connect(self.lineEditIEPSI, SIGNAL("textChanged(const QString &)"), self.slotIEPSI) self.connect(self.comboBoxIJRDP, SIGNAL("activated(const QString&)"), self.slotIJRDP) self.connect(self.lineEditIDPT, SIGNAL("textChanged(const QString &)"), self.slotIDPT) self.connect(self.lineEditIVDPT, SIGNAL("textChanged(const QString &)"), self.slotIVDPT) self.connect(self.lineEditINUCHL, SIGNAL("textChanged(const QString &)"), self.slotINUCHL) self.connect(self.lineEditIHPT, SIGNAL("textChanged(const QString &)"), self.slotIHPT) self.connect(self.comboBoxIRAWCL, SIGNAL("activated(const QString&)"), self.slotIRAWCL) # Validators validatorIJNBP = IntValidator(self.lineEditIJNBP, min=0) validatorIJFRE = IntValidator(self.lineEditIJFRE, min=0) validatorICLST = IntValidator(self.lineEditICLST, min=0) validatorIDEBT = DoubleValidator(self.lineEditIDEBT, min=0.) validatorIPOIT = DoubleValidator(self.lineEditIPOIT, min=0.) validatorIPOIT.setExclusiveMin(True) validatorIROPT = DoubleValidator(self.lineEditIROPT, min=0.) validatorIROPT.setExclusiveMin(True) validatorIUNO = DoubleValidator(self.lineEditIUNO) validatorIUPT = DoubleValidator(self.lineEditIUPT) validatorIVPT = DoubleValidator(self.lineEditIVPT) validatorIWPT = DoubleValidator(self.lineEditIWPT) validatorITPT = DoubleValidator(self.lineEditITPT) validatorICPT = DoubleValidator(self.lineEditICPT) validatorIEPSI = DoubleValidator(self.lineEditIEPSI) validatorIDPT = DoubleValidator(self.lineEditIDPT, min=0.) validatorIVDPT = DoubleValidator(self.lineEditIVDPT) validatorINUCHL = IntValidator(self.lineEditINUCHL, min=0) validatorIHPT = DoubleValidator(self.lineEditIHPT) self.lineEditIJNBP.setValidator(validatorIJNBP) self.lineEditIJFRE.setValidator(validatorIJFRE) self.lineEditICLST.setValidator(validatorICLST) self.lineEditIDEBT.setValidator(validatorIDEBT) self.lineEditIPOIT.setValidator(validatorIPOIT) self.lineEditIROPT.setValidator(validatorIROPT) self.lineEditIUNO.setValidator(validatorIUNO) self.lineEditIUPT.setValidator(validatorIUPT) self.lineEditIVPT.setValidator(validatorIVPT) self.lineEditIWPT.setValidator(validatorIWPT) self.lineEditITPT.setValidator(validatorITPT) self.lineEditICPT.setValidator(validatorICPT) self.lineEditIEPSI.setValidator(validatorIEPSI) self.lineEditIDPT.setValidator(validatorIDPT) self.lineEditIVDPT.setValidator(validatorIVDPT) self.lineEditINUCHL.setValidator(validatorINUCHL) self.lineEditIHPT.setValidator(validatorIHPT) self._hideAllWidgets() self.case.undoStartGlobal() def _hideAllWidgets(self): self.groupBoxClassNumber.hide() self.groupBoxMain.hide() self.groupBoxRate.hide() self.groupBoxVelocity.hide() self.groupBoxTemperature.hide() self.groupBoxDiameter.hide() self.groupBoxCoal.hide() @pyqtSignature("const QModelIndex&") def slotSelectBoundary(self, index): """ """ self._hideAllWidgets() label, nature, interaction, nclasses = self.modelBoundaries.getItem(index.row()) self.label = label if interaction != "inlet": return self.model.setCurrentBoundaryNode(nature, label) if nclasses > 0: self.groupBoxClassNumber.show() self.spinBoxICLAS.setMinimum(1) self.spinBoxICLAS.setMaximum(nclasses) self.spinBoxICLAS.setValue(1) self.slotICLAS(1) @pyqtSignature("const QModelIndex &, const QModelIndex &") def dataChanged(self, topLeft, bottomRight): """ """ self.slotSelectBoundary(topLeft) @pyqtSignature("int") def slotICLAS(self, iclass): """ Input ICLAS. """ self.iclass = iclass index = self.tableViewBoundaries.currentIndex() label, nature, interaction, nclasses = self.modelBoundaries.getItem(index.row()) if interaction == "inlet": self.model.setCurrentClassNode(self.label, iclass) self.LM = LagrangianModel(self.case) part_model = self.LM.getParticlesModel() # Main variables self.groupBoxMain.show() npart = self.model.getNumberOfParticulesInClassValue(self.label, self.iclass) self.lineEditIJNBP.setText(str(npart)) freq = self.model.getInjectionFrequencyValue(self.label, self.iclass) self.lineEditIJFRE.setText(str(freq)) self.LSM = LagrangianStatisticsModel(self.case) if self.LSM.getGroupOfParticlesValue() > 0: igroup = self.model.getParticleGroupNumberValue(self.label, self.iclass) self.lineEditICLST.setText(str(igroup)) else: self.labelICLST.setDisabled(True) self.lineEditICLST.setDisabled(True) # Rate / stat. weight self.groupBoxRate.show() choice = self.model.getStatisticalWeightChoice(self.label, self.iclass) self.modelIPOIT.setItem(str_model=choice) text = self.modelIPOIT.dicoM2V[choice] self.slotIPOITChoice(text) # Velocity self.groupBoxVelocity.show() choice = self.model.getVelocityChoice(self.label, self.iclass) self.modelIJUVW.setItem(str_model=choice) text = self.modelIJUVW.dicoM2V[choice] self.slotIJUVW(text) # Temperature status = self.LM.getHeating() if part_model == "thermal" and status == "on": self.groupBoxTemperature.show() choice = self.model.getTemperatureChoice(self.label, self.iclass) self.modelIJRTP.setItem(str_model=choice) text = self.modelIJRTP.dicoM2V[choice] self.slotIJRTP(text) cp = self.model.getSpecificHeatValue(self.label, self.iclass) self.lineEditICPT.setText(str(cp)) eps = self.model.getEmissivityValue(self.label, self.iclass) self.lineEditIEPSI.setText(str(eps)) # Coals if CoalCombustionModel(self.case).getCoalCombustionModel() != 'off': self.groupBoxCoal.show() icoal = self.model.getCoalNumberValue(self.label, self.iclass) self.lineEditINUCHL.setText(str(icoal)) temp = self.model.getCoalTemperatureValue(self.label, self.iclass) self.lineEditIHPT.setText(str(temp)) choice = self.model.getCoalCompositionChoice(self.label, self.iclass) self.modelIRAWCL.setItem(str_model=choice) # Diameter self.groupBoxDiameter.show() choice = self.model.getDiameterChoice(self.label, self.iclass) if part_model == "coal": self.modelIJRDP.setItem(str_model="prescribed") else: self.modelIJRDP.setItem(str_model=choice) text = self.modelIJRDP.dicoM2V[choice] self.slotIJRDP(text) if choice == "prescribed": self.frameDiameter.show() diam = self.model.getDiameterValue(self.label, self.iclass) vdiam = self.model.getDiameterVarianceValue(self.label, self.iclass) self.lineEditIDPT.setText(str(diam)) self.lineEditIVDPT.setText(str(vdiam)) elif choice == "subroutine": self.frameDiameter.hide() #Coal if CoalCombustionModel(self.case).getCoalCombustionModel() != 'off': self.labelIROPT.hide() self.labelUnitIROPT.hide() self.lineEditIROPT.hide() else: self.labelIROPT.show() self.labelUnitIROPT.show() self.lineEditIROPT.show() rho = self.model.getDensityValue(self.label, self.iclass) self.lineEditIROPT.setText(str(rho)) @pyqtSignature("const QString&") def slotIJNBP(self, text): """ Input IJNBP. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.setNumberOfParticulesInClassValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIJFRE(self, text): """ Input IJFRE. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.setInjectionFrequencyValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotICLST(self, text): """ Input ICLST. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.setParticleGroupNumberValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIDEBT(self, text): """ Input IDEBT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setMassFlowRateValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIPOITChoice(self, text): """ Input IPOIT. """ choice = self.modelIPOIT.dicoV2M[str(text)] self.model.setStatisticalWeightChoice(self.label, self.iclass, choice) self.frameVolumicRate.hide() self.frameStatisticalWeight.hide() if choice == "rate": self.frameVolumicRate.show() rate = self.model.getMassFlowRateValue(self.label, self.iclass) self.lineEditIDEBT.setText(str(rate)) self.model.setStatisticalWeightValue(self.label, self.iclass, 1) elif choice == "prescribed": self.frameStatisticalWeight.show() weight = self.model.getStatisticalWeightValue(self.label, self.iclass) self.lineEditIPOIT.setText(str(weight)) elif choice == "subroutine": pass @pyqtSignature("const QString&") def slotIPOIT(self, text): """ Input IPOIT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setStatisticalWeightValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIROPT(self, text): """ Input IROPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setDensityValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIJUVW(self, text): """ Input IJUVW. """ choice = self.modelIJUVW.dicoV2M[str(text)] self.model.setVelocityChoice(self.label, self.iclass, choice) self.frameVelocityNorm.hide() self.frameVelocityValues.hide() if choice == "norm": self.frameVelocityNorm.show() norm = self.model.getVelocityNormValue(self.label, self.iclass) self.lineEditIUNO.setText(str(norm)) elif choice == "components": self.frameVelocityValues.show() vu = self.model.getVelocityDirectionValue(self.label, self.iclass, "u") vv = self.model.getVelocityDirectionValue(self.label, self.iclass, "v") vw = self.model.getVelocityDirectionValue(self.label, self.iclass, "w") self.lineEditIUPT.setText(str(vu)) self.lineEditIVPT.setText(str(vv)) self.lineEditIWPT.setText(str(vw)) @pyqtSignature("const QString&") def slotIUNO(self, text): """ Input IUNO. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setVelocityNormValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIUPT(self, text): """ Input IUPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setVelocityDirectionValue(self.label, self.iclass, "u", value) @pyqtSignature("const QString&") def slotIVPT(self, text): """ Input IVPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setVelocityDirectionValue(self.label, self.iclass, "v", value) @pyqtSignature("const QString&") def slotIWPT(self, text): """ Input IWPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setVelocityDirectionValue(self.label, self.iclass, "w", value) @pyqtSignature("const QString&") def slotIJRTP(self, text): """ Input IJRTP. """ choice = self.modelIJRTP.dicoV2M[str(text)] self.model.setTemperatureChoice(self.label, self.iclass, choice) if choice == "prescribed": self.frameTemperature.show() temp = self.model.getTemperatureValue(self.label, self.iclass) self.lineEditITPT.setText(str(temp)) elif choice == "subroutine": self.frameTemperature.hide() @pyqtSignature("const QString&") def slotITPT(self, text): """ Input ITPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setTemperatureValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotICPT(self, text): """ Input ICPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setSpecificHeatValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIEPSI(self, text): """ Input IEPSI. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setEmissivityValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIJRDP(self, text): """ Input IJRDP. """ choice = self.modelIJRDP.dicoV2M[str(text)] self.model.setDiameterChoice(self.label, self.iclass, choice) if choice == "prescribed": self.frameDiameter.show() diam = self.model.getDiameterValue(self.label, self.iclass) vdiam = self.model.getDiameterVarianceValue(self.label, self.iclass) self.lineEditIDPT.setText(str(diam)) self.lineEditIVDPT.setText(str(vdiam)) elif choice == "subroutine": self.frameDiameter.hide() @pyqtSignature("const QString&") def slotIDPT(self, text): """ Input IDPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setDiameterValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIVDPT(self, text): """ Input IVDPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setDiameterVarianceValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotINUCHL(self, text): """ Input IHPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.setCoalNumberValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIHPT(self, text): """ Input IHPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setCoalTemperatureValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIRAWCL(self, text): """ Input IJRDP. """ choice = self.modelIRAWCL.dicoV2M[str(text)] self.model.setCoalCompositionChoice(self.label, self.iclass, choice) def tr(self, text): """ Translation """ return text
class TurbulenceView(QWidget, Ui_Turbulence): """ Main fields layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_Turbulence.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = TurbulenceModel(self.case) # Dico self.dicoM2V = { "none": 'none', "mixing_length": 'mixing length', "k-epsilon": 'k-epsilon', "rij-epsilon_ssg": 'Rij-epsilon SSG', "rij-epsilon_ebrsm": 'Rij-epsilon EBRSM', "k-epsilon_linear_production": 'k-epsilon linear production', "les_smagorinsky": 'LES (Smagorinsky)', "les_wale": 'LES (WALE)', "tchen": 'Tchen', "q2-q12": 'Q2-Q12', "r2-q12": 'R2-Q12', "r2-r12-tchen": 'R2-R12 Tchen', "separate_phase": 'separate phase', "separate_phase_cond": 'separate phase cond', "small_inclusions": 'small inclusions', "large_inclusions": 'large inclusions', "sgdh": 'SGDH', "ggdh": 'GGDH' } self.dicoV2M = { "none": 'none', "mixing length": 'mixing_length', "k-epsilon": 'k-epsilon', "Rij-epsilon SSG": 'rij-epsilon_ssg', "Rij-epsilon EBRSM": 'rij-epsilon_ebrsm', "k-epsilon linear production": 'k-epsilon_linear_production', "LES (Smagorinsky)": 'les_smagorinsky', "LES (WALE)": 'les_wale', "Tchen": 'tchen', "Q2-Q12": 'q2-q12', "R2-Q12": 'r2-q12', "R2-R12 Tchen": 'r2-r12-tchen', "separate phase": 'separate_phase', "separate phase cond": 'separate_phase_cond', "small inclusions": 'small_inclusions', "large inclusions": 'large_inclusions', "SGDH": 'sgdh', "GGDH": 'ggdh' } # Validators validatorMix = DoubleValidator(self.lineEditMixingLength, min=0.0) validatorMix.setExclusiveMin(False) self.lineEditMixingLength.setValidator(validatorMix) self.tableModelTurbulence = StandardItemModelTurbulence( self.mdl, self.case, self.dicoM2V, self.dicoV2M) self.tableViewTurbulence.setModel(self.tableModelTurbulence) self.tableViewTurbulence.resizeColumnsToContents() self.tableViewTurbulence.resizeRowsToContents() if QT_API == "PYQT4": self.tableViewTurbulence.verticalHeader().setResizeMode( QHeaderView.ResizeToContents) self.tableViewTurbulence.horizontalHeader().setResizeMode( QHeaderView.ResizeToContents) self.tableViewTurbulence.horizontalHeader().setResizeMode( 0, QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewTurbulence.verticalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.tableViewTurbulence.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.tableViewTurbulence.horizontalHeader().setSectionResizeMode( 0, QHeaderView.Stretch) self.tableViewTurbulence.setSelectionBehavior( QAbstractItemView.SelectRows) self.tableViewTurbulence.setSelectionMode( QAbstractItemView.SingleSelection) delegateTurbulence = TurbulenceDelegate(self.tableViewTurbulence, self.mdl, self.dicoM2V, self.dicoV2M) delegateTurbFlux = TurbFluxDelegate(self.tableViewTurbulence, self.mdl, self.dicoM2V, self.dicoV2M) delegateCoupling = CouplingDelegate(self.tableViewTurbulence, self.mdl, self.dicoM2V, self.dicoV2M) self.tableViewTurbulence.setItemDelegateForColumn( 2, delegateTurbulence) self.tableViewTurbulence.setItemDelegateForColumn(3, delegateTurbFlux) self.tableViewTurbulence.setItemDelegateForColumn(4, delegateCoupling) # Combo models self.modelContinuousCoupling = ComboModel( self.comboBoxContinuousCoupling, 3, 1) self.modelContinuousCoupling.addItem(self.tr('none'), 'none') self.modelContinuousCoupling.addItem(self.tr("separate phases"), "separate_phase") self.modelContinuousCoupling.addItem(self.tr("separate phases + cond"), "separate_phase_cond") # hide groupBoxMixingLength self.groupBoxMixingLength.hide() # Connect signals to slots self.tableModelTurbulence.dataChanged.connect(self.dataChanged) self.lineEditMixingLength.textChanged[str].connect( self.slotMixingLength) self.tableViewTurbulence.clicked.connect(self.slotChangeSelection) self.comboBoxContinuousCoupling.activated[str].connect( self.slotContinuousCoupling) # hide/show groupBoxContinuousCoupling if len(self.mdl.getContinuousFieldList()) >= 2: self.groupBoxContinuousCoupling.show() model = self.mdl.getContinuousCouplingModel() self.modelContinuousCoupling.setItem(str_model=model) else: self.groupBoxContinuousCoupling.hide() for fieldId in self.mdl.getFieldIdList(): self.tableModelTurbulence.newItem(fieldId) self.case.undoStartGlobal() def slotChangeSelection(self, text=None): """ detect change selection to update """ row = self.tableViewTurbulence.currentIndex().row() self.update(row) def dataChanged(self, topLeft, bottomRight): self.tableViewTurbulence.resizeColumnsToContents() self.tableViewTurbulence.resizeRowsToContents() if QT_API == "PYQT4": self.tableViewTurbulence.horizontalHeader().setResizeMode( 0, QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewTurbulence.horizontalHeader().setSectionResizeMode( 0, QHeaderView.Stretch) row = self.tableViewTurbulence.currentIndex().row() self.update(row) def update(self, row): """ show groupBoxMixingLength if necessary """ fieldId = row + 1 if fieldId != 0: turbModel = self.mdl.getTurbulenceModel(fieldId) if turbModel == "mixing_length": self.groupBoxMixingLength.show() self.lineEditMixingLength.setText( str(self.mdl.getMixingLength(fieldId))) else: self.groupBoxMixingLength.hide() # If the user chose GGDH for a RSM turbulence model, we set # the thermal fluxes model back to SGDH for consistency if 'rij-epsilon' not in turbModel and \ self.mdl.getThermalTurbulentFlux(fieldId) == 'ggdh': self.mdl.setThermalTurbulentFlux(fieldId, 'sgdh') @pyqtSlot(str) def slotMixingLength(self, text): """ Update the mixing length """ fieldId = self.tableViewTurbulence.currentIndex().row() + 1 if self.lineEditMixingLength.validator( ).state == QValidator.Acceptable: mix = from_qvariant(text, float) self.mdl.setMixingLength(fieldId, mix) @pyqtSlot(str) def slotContinuousCoupling(self, text): """ define continuous/continuous coupling modele """ value = self.modelContinuousCoupling.dicoV2M[text] log.debug("slotContinuousCoupling -> %s" % value) self.mdl.setContinuousCouplingModel(value)
class BoundaryConditionsCoalInletView(QWidget, Ui_BoundaryConditionsCoalInletForm): def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsCoalInletForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() # Connections self.connect(self.comboBoxTypeInlet, SIGNAL("activated(const QString&)"), self.__slotInletType) self.connect(self.comboBoxVelocity, SIGNAL("activated(const QString&)"), self.__slotChoiceVelocity) self.connect(self.lineEditVelocity, SIGNAL("textChanged(const QString &)"), self.__slotVelocityValue) self.connect(self.lineEditTemperature, SIGNAL("textChanged(const QString &)"), self.__slotTemperature) self.connect(self.spinBoxOxydantNumber, SIGNAL("valueChanged(int)"), self.__slotOxydantNumber) self.connect(self.comboBoxDirection, SIGNAL("activated(const QString&)"), self.__slotChoiceDirection) self.connect(self.lineEditDirectionX, SIGNAL("textChanged(const QString &)"), self.__slotDirX) self.connect(self.lineEditDirectionY, SIGNAL("textChanged(const QString &)"), self.__slotDirY) self.connect(self.lineEditDirectionZ, SIGNAL("textChanged(const QString &)"), self.__slotDirZ) # Combo models self.modelTypeInlet = ComboModel(self.comboBoxTypeInlet, 2, 1) self.modelTypeInlet.addItem(self.tr("only oxydant"), 'oxydantFlow') self.modelTypeInlet.addItem(self.tr("oxydant and coal"), 'coalFlow') self.modelVelocity = ComboModel(self.comboBoxVelocity, 4, 1) self.modelVelocity.addItem(self.tr("norm"), 'norm') self.modelVelocity.addItem(self.tr("mass flow rate"), 'flow1') self.modelVelocity.addItem(self.tr("norm (user law)"), 'norm_formula') self.modelVelocity.addItem(self.tr("mass flow rate (user law)"), 'flow1_formula') self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("normal to the inlet"), 'normal') self.modelDirection.addItem(self.tr("specified coordinates"), 'coordinates') self.modelDirection.addItem(self.tr("user profile"), 'formula') # Validators validatorVelocity = DoubleValidator(self.lineEditVelocity) validatorX = DoubleValidator(self.lineEditDirectionX) validatorY = DoubleValidator(self.lineEditDirectionY) validatorZ = DoubleValidator(self.lineEditDirectionZ) validatorTemp = DoubleValidator(self.lineEditTemperature, min=0.) # Apply validators self.lineEditVelocity.setValidator(validatorVelocity) self.lineEditDirectionX.setValidator(validatorX) self.lineEditDirectionY.setValidator(validatorY) self.lineEditDirectionZ.setValidator(validatorZ) self.lineEditTemperature.setValidator(validatorTemp) self.connect(self.pushButtonVelocityFormula, SIGNAL("clicked()"), self.__slotVelocityFormula) self.connect(self.pushButtonDirectionFormula, SIGNAL("clicked()"), self.__slotDirectionFormula) # Useful information about coals, classes, and ratios mdl = CoalCombustion.CoalCombustionModel(self.__case) if mdl.getCoalCombustionModel() != "off": self.__coalNumber = mdl.getCoalNumber() self.__coalClassesNumber = [] for coal in range(0, self.__coalNumber): self.__coalClassesNumber.append(mdl.getClassNumber(str(coal+1))) self.__maxOxydantNumber = mdl.getOxidantNumber() else: self.__coalNumber = 0 self.__coalClassesNumber = [0] self.__maxOxydantNumber = 1 self.__ratio = self.__coalNumber*[0] for i in range(0, self.__coalNumber): self.__ratio[i] = self.__coalClassesNumber[i]*[0] # Coal table self.__modelCoal = StandardItemModelCoal(self.__case) self.tableViewCoal.setModel(self.__modelCoal) delegateValue = ValueDelegate(self.tableViewCoal) self.tableViewCoal.setItemDelegateForColumn(1, delegateValue) self.tableViewCoal.setItemDelegateForColumn(2, delegateValue) # Coal mass ratio table self.__modelCoalMass = StandardItemModelCoalMass(self.__case, self.__coalNumber, self.__coalClassesNumber) self.tableViewCoalMass.setModel(self.__modelCoalMass) delegateValueMass = ValueDelegate(self.tableViewCoalMass) for c in range(self.__modelCoalMass.columnCount()): self.tableViewCoalMass.setItemDelegateForColumn(c, delegateValueMass) self.__case.undoStartGlobal() def showWidget(self, b): """ Show the widget """ label = b.getLabel() self.__boundary = Boundary('coal_inlet', label, self.__case) # Initialize velocity choice = self.__boundary.getVelocityChoice() self.modelVelocity.setItem(str_model=choice) self.__updateLabel() if choice[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) self.lineEditVelocity.setEnabled(False) else: self.pushButtonVelocityFormula.setEnabled(False) self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) # Initialize oxydant and temperature self.spinBoxOxydantNumber.setMaximum(self.__maxOxydantNumber) o = self.__boundary.getOxydantNumber() self.spinBoxOxydantNumber.setValue(o) t = self.__boundary.getOxydantTemperature() self.lineEditTemperature.setText(str(t)) # Initialize direction choice = self.__boundary.getDirectionChoice() self.modelDirection.setItem(str_model=choice) text = self.modelDirection.dicoM2V[choice] if choice == "formula": self.pushButtonDirectionFormula.setEnabled(True) self.frameDirectionCoordinates.hide() elif choice == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif choice == "normal": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.hide() log.debug("showWidget:inlet type: %s " % self.__boundary.getInletType()) if self.__boundary.getInletType() == "coalFlow": self.modelTypeInlet.setItem(str_model="coalFlow") self.groupBoxCoal.show() self.groupBoxCoalMass.show() self.__updateTables() self.__boundary.setInletType("coalFlow") else: self.__boundary.setInletType("oxydantFlow") self.modelTypeInlet.setItem(str_model="oxydantFlow") self.groupBoxCoal.hide() self.groupBoxCoalMass.hide() self.show() def hideWidget(self): """ Hide all """ self.hide() def __updateTables(self): """ Insert rows in the two QTableView. """ # clean the QTableView self.__modelCoal.deleteAll() self.__modelCoalMass.deleteAll() label = self.__boundary.getLabel() self.__modelCoalMass.setBoundaryFromLabel(label) self.__modelCoal.setBoundaryFromLabel(label) # fill the flow and temperature of the coal for coal in range(0, self.__coalNumber): self.__modelCoal.insertItem(self.tr("Coal ") + " " + str(coal+1), self.__boundary.getCoalFlow(coal), self.__boundary.getCoalTemperature(coal)) # fill the ratio of mass for each class for each coal for coal in range(0, self.__coalNumber) : lastValue = 0. for coalClass in range(0, self.__coalClassesNumber[coal]-1): lst = self.__boundary.getCoalRatios(coal) lastValue += lst[coalClass] self.__ratio[coal][coalClass] = lst[coalClass] # last class is computed in order to assure that sum is egal to 100% coalClass = self.__coalClassesNumber[coal]-1 lastValue = 100 - lastValue self.__ratio[coal][coalClass] = lastValue self.__modelCoalMass.setRatio(self.__ratio) @pyqtSignature("const QString&") def __slotChoiceVelocity(self, text): """ Private slot. Input the velocity boundary type choice (norm, ). @type text: C{QString} @param text: velocity boundary type choice. """ c = self.modelVelocity.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setVelocityChoice(c) if c[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) setGreenColor(self.pushButtonVelocityFormula, True) self.lineEditVelocity.setEnabled(False) self.lineEditVelocity.setText("") else: self.pushButtonVelocityFormula.setEnabled(False) setGreenColor(self.pushButtonVelocityFormula, False) self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) self.__updateLabel() def __updateLabel(self): """ Update the unit for the velocity specification. """ c = self.__boundary.getVelocityChoice() if c in ('norm', 'norm_formula'): self.labelUnitVelocity.setText(str('m/s')) elif c in ('flow1', 'flow1_formula'): self.labelUnitVelocity.setText(str('kg/s')) elif c in ('flow2', 'flow2_formula'): self.labelUnitVelocity.setText(str('m<sup>3</sup>/s')) @pyqtSignature("const QString&") def __slotVelocityValue(self, text): """ Private slot. New value associated to the velocity boundary type. @type text: C{QString} @param text: value """ if self.sender().validator().state == QValidator.Acceptable: v = from_qvariant(text, float) self.__boundary.setVelocity(v) @pyqtSignature("") def __slotVelocityFormula(self): """ """ exp = self.__boundary.getVelocity() c = self.__boundary.getVelocityChoice() if c == 'norm_formula': exa = "u_norm = 1.0;" req = [('u_norm', 'Norm of the velocity')] elif c == 'flow1_formula': exa = "q_m = 1.0;" req = [('q_m', 'mass flow rate')] elif c == 'flow2_formula': exa = "q_v = 1.0;" req = [('q_v', 'volumic flow rate')] sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] 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("slotFormulaVelocity -> %s" % str(result)) self.__boundary.setVelocity(result) setGreenColor(self.pushButtonVelocityFormula, False) @pyqtSignature("const QString&") def __slotChoiceDirection(self, text): """ Input the direction type choice. """ c = self.modelDirection.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setDirectionChoice(c) if c == "formula": self.pushButtonDirectionFormula.setEnabled(True) setGreenColor(self.pushButtonDirectionFormula, True) self.frameDirectionCoordinates.hide() elif c == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) setGreenColor(self.pushButtonDirectionFormula, False) self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif c == "normal": self.pushButtonDirectionFormula.setEnabled(False) setGreenColor(self.pushButtonDirectionFormula, False) self.frameDirectionCoordinates.hide() @pyqtSignature("const QString&") def __slotDirX(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_x', value) @pyqtSignature("const QString&") def __slotDirY(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_y', value) @pyqtSignature("const QString&") def __slotDirZ(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_z', value) @pyqtSignature("") def __slotDirectionFormula(self): """ """ exp = self.__boundary.getDirection('direction_formula') req = [('dir_x', 'Direction of the flow along X'), ('dir_y', 'Direction of the flow along Y'), ('dir_z', 'Direction of the flow along Z')] exa = "dir_x = 3.0;\ndir_y = 1.0;\ndir_z = 0.0;\n" sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] 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("slotFormulaDirection -> %s" % str(result)) self.__boundary.setDirection('direction_formula', result) setGreenColor(self.pushButtonDirectionFormula, False) @pyqtSignature("const QString&") def __slotInletType(self, text): """ INPUT inlet type : 'oxydant' or 'oxydant + coal' """ value = self.modelTypeInlet.dicoV2M[str(text)] log.debug("__slotInletType value = %s " % value) self.__boundary.setInletType(value) if value == 'oxydantFlow': self.groupBoxCoal.hide() self.groupBoxCoalMass.hide() else: self.groupBoxCoal.show() self.groupBoxCoalMass.show() self.__updateTables() @pyqtSignature("const QString&") def __slotTemperature(self, text): if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setOxydantTemperature(t) @pyqtSignature("int") def __slotOxydantNumber(self, i): self.__boundary.setOxydantNumber(i) def getCoalNumber(self): """ Return the coal number """ return self.__coalNumber def tr(self, text): """ Translation """ return text
class BoundaryConditionsMobileMeshView(QWidget, Ui_BoundaryConditionsMobileMeshForm): """ Boundary condifition for mobil mesh (ALE and/or Fluid-interaction) """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsMobileMeshForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget """ self.case = case self.__boundary = None self.case.undoStopGlobal() self.__model = MobileMeshModel(self.case) self.notebook = NotebookModel(self.case) self.__comboModel = ComboModel(self.comboMobilBoundary, 6, 1) self.__comboModel.addItem(self.tr("Fixed boundary"), "fixed_boundary") self.__comboModel.addItem(self.tr("Sliding boundary"), "sliding_boundary") self.__comboModel.addItem(self.tr("Internal coupling"), "internal_coupling") self.__comboModel.addItem(self.tr("External coupling"), "external_coupling") self.__comboModel.addItem(self.tr("Fixed velocity"), "fixed_velocity") self.__comboModel.addItem(self.tr("Fixed displacement"), "fixed_displacement") self.comboMobilBoundary.activated[str].connect(self.__slotCombo) self.pushButtonMobilBoundary.clicked.connect(self.__slotFormula) self.case.undoStartGlobal() @pyqtSlot() def __slotFormula(self): """ Run formula editor. """ exp = self.__boundary.getALEFormula() c = self.__boundary.getALEChoice(); if c == "fixed_velocity": if not exp: exp = 'mesh_velocity[0] = 0.;\nmesh_velocity[1] = 0.;\nmesh_velocity[2] = 0.;' req = [('mesh_velocity[0]', 'Fixed velocity of the mesh'), ('mesh_velocity[1]', 'Fixed velocity of the mesh'), ('mesh_velocity[2]', 'Fixed velocity of the mesh')] exa = 'mesh_velocity[0] = 0.;\nmesh_velocity[1] = 0.;\nmesh_velocity[2] = 1.;' elif c == "fixed_displacement": if not exp: exp = 'mesh_displacement[0] = 0.;\nmesh_displacement[1] = 0.;\nmesh_displacement[2] = 0.;' req = [('mesh_displacement[0]', 'Fixed displacement of the mesh'), ('mesh_displacement[1]', 'Fixed displacement of the mesh'), ('mesh_displacement[2]', 'Fixed displacement of the mesh')] exa = 'mesh_displacement[0] = 0.;\nmesh_displacement[1] = 0.;\nmesh_displacement[2] = 1.;' sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration'), ('surface', 'Boundary zone surface')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMegEditorView(parent = self, function_type = 'bnd', zone_name = self.__boundary._label, variable_name = 'mesh_velocity', expression = exp, required = req, symbols = sym, condition = c, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMobileMeshBoundary -> %s" % str(result)) self.__boundary.setFormula(str(result)) self.pushButtonMobilBoundary.setStyleSheet("background-color: green") self.pushButtonMobilBoundary.setToolTip(result) @pyqtSlot(str) def __slotCombo(self, text): """ Called when the combobox changed. """ modelData = self.__comboModel.dicoV2M[str(text)] if modelData == self.__boundary.getALEChoice(): return self.__boundary.setALEChoice(modelData) exp = self.__boundary.getALEFormula() # Hide/Show formula button. # Formula is always reset when changing values, so set # color to red. if modelData in ["fixed_velocity", "fixed_displacement"]: self.pushButtonMobilBoundary.show() else: self.pushButtonMobilBoundary.hide() if exp: self.pushButtonMobilBoundary.setStyleSheet("background-color: red") self.pushButtonMobilBoundary.setToolTip(exp) else: self.pushButtonMobilBoundary.setStyleSheet("background-color: red") def showWidget(self, b): """ Show the widget """ if self.__model.getMethod() != "off": self.__boundary = b modelData = b.getALEChoice() self.__comboModel.setItem(str_model=modelData) if modelData in ["fixed_velocity", "fixed_displacement"]: self.pushButtonMobilBoundary.show() else: self.pushButtonMobilBoundary.hide() self.show() else: self.hideWidget() def hideWidget(self): """ Hide all """ self.hide()
class BoundaryConditionsTurbulenceInletView(QWidget, Ui_BoundaryConditionsTurbulenceInletForm): """ Boundary condition for turbulence """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsTurbulenceInletForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.connect(self.comboBoxTurbulence, SIGNAL("activated(const QString&)"), self.__slotChoiceTurbulence) self.__modelTurbulence = ComboModel(self.comboBoxTurbulence, 2, 1) self.__modelTurbulence.addItem(self.tr("Calculation by hydraulic diameter"), 'hydraulic_diameter') self.__modelTurbulence.addItem(self.tr("Calculation by turbulent intensity"), 'turbulent_intensity') self.__modelTurbulence.addItem(self.tr("Calculation by formula"), 'formula') self.connect(self.lineEditDiameter, SIGNAL("textChanged(const QString &)"), self.__slotDiam) self.connect(self.lineEditIntensity, SIGNAL("textChanged(const QString &)"), self.__slotIntensity) self.connect(self.lineEditDiameterIntens, SIGNAL("textChanged(const QString &)"), self.__slotDiam) self.connect(self.pushButtonTurb, SIGNAL("clicked()"), self.__slotTurbulenceFormula) validatorDiam = DoubleValidator(self.lineEditDiameter, min=0.) validatorDiam.setExclusiveMin(True) validatorIntensity = DoubleValidator(self.lineEditIntensity, min=0.) self.lineEditDiameter.setValidator(validatorDiam) self.lineEditDiameterIntens.setValidator(validatorDiam) self.lineEditIntensity.setValidator(validatorIntensity) self.__case.undoStartGlobal() def showWidget(self, boundary): """ Show the widget """ self.__boundary = boundary if TurbulenceModel(self.__case).getTurbulenceVariable(): turb_choice = boundary.getTurbulenceChoice() self.__modelTurbulence.setItem(str_model=turb_choice) if turb_choice == "hydraulic_diameter": self.frameTurbDiameter.show() self.frameTurbIntensity.hide() self.pushButtonTurb.setEnabled(False) setGreenColor(self.pushButtonTurb, False) d = boundary.getHydraulicDiameter() self.lineEditDiameter.setText(str(d)) elif turb_choice == "turbulent_intensity": self.frameTurbIntensity.show() self.frameTurbDiameter.hide() self.pushButtonTurb.setEnabled(False) setGreenColor(self.pushButtonTurb, False) i = boundary.getTurbulentIntensity() d = boundary.getHydraulicDiameter() self.lineEditIntensity.setText(str(i)) self.lineEditDiameterIntens.setText(str(d)) elif turb_choice == "formula": self.frameTurbIntensity.hide() self.frameTurbDiameter.hide() self.pushButtonTurb.setEnabled(True) setGreenColor(self.pushButtonTurb, True) self.show() else: self.hideWidget() def hideWidget(self): """ Hide the widget """ self.hide() @pyqtSignature("const QString&") def __slotChoiceTurbulence(self, text): """ INPUT choice of method of calculation of the turbulence """ turb_choice = self.__modelTurbulence.dicoV2M[str(text)] self.__boundary.setTurbulenceChoice(turb_choice) self.frameTurbDiameter.hide() self.frameTurbIntensity.hide() self.pushButtonTurb.setEnabled(False) setGreenColor(self.pushButtonTurb, False) if turb_choice == 'hydraulic_diameter': self.frameTurbDiameter.show() d = self.__boundary.getHydraulicDiameter() self.lineEditDiameter.setText(str(d)) elif turb_choice == 'turbulent_intensity': self.frameTurbIntensity.show() i = self.__boundary.getTurbulentIntensity() self.lineEditIntensity.setText(str(i)) d = self.__boundary.getHydraulicDiameter() self.lineEditDiameterIntens.setText(str(d)) elif turb_choice == 'formula': self.pushButtonTurb.setEnabled(True) setGreenColor(self.pushButtonTurb, True) @pyqtSignature("const QString&") def __slotDiam(self, text): """ INPUT hydraulic diameter """ if self.sender().validator().state == QValidator.Acceptable: diam = from_qvariant(text, float) self.__boundary.setHydraulicDiameter(diam) @pyqtSignature("const QString&") def __slotIntensity(self, text): """ INPUT turbulent intensity """ if self.sender().validator().state == QValidator.Acceptable: intens = from_qvariant(text, float) self.__boundary.setTurbulentIntensity(intens) @pyqtSignature("") def __slotTurbulenceFormula(self): """ INPUT user formula """ turb_model = TurbulenceModel(self.__case).getTurbulenceModel() if turb_model in ('k-epsilon', 'k-epsilon-PL'): exp = self.__boundary.getTurbFormula() if not exp: exp = self.__boundary.getDefaultTurbFormula(turb_model) exa = """#example : uref2 = 10.; dh = 0.2; re = sqrt(uref2)*dh*rho0/mu0; if (re < 2000){ # in this case u*^2 is directly calculated to not have a problem with # xlmbda=64/Re when Re->0 ustar2 = 8.*mu0*sqrt(uref2)/rho0/dh;} else if (re<4000){ xlmbda = 0.021377 + 5.3115e-6*re; ustar2 = uref2*xlmbda/8.;} else { xlmbda = 1/( 1.8*log(re)/log(10.)-1.64)^2; ustar2 = uref2*xlmbda/8.;} cmu = 0.09; kappa = 0.42; k = ustar2/sqrt(cmu); epsilon = ustar2^1.5/(kappa*dh*0.1);""" req = [('k', "turbulent energy"), ('epsilon', "turbulent dissipation")] sym = [('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'), ('t','time'), ('dt','time step'), ('iter','number of time step')] 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("slotFormulaTurb -> %s" % str(result)) self.__boundary.setTurbFormula(result) setGreenColor(self.pushButtonTurb, False) elif turb_model in ('Rij-epsilon', 'Rij-SSG'): exp = self.__boundary.getTurbFormula() if not exp: exp = self.__boundary.getDefaultTurbFormula(turb_model) exa = """#exemple : uref2 = 10.; dh = 0.2; re = sqrt(uref2)*dh*rho0/mu0; if (re < 2000){ # in this case u*^2 is directly calculated to not have a problem with # xlmbda=64/Re when Re->0 ustar2 = 8.*mu0*sqrt(uref2)/rho0/dh;} else if (re<4000){ xlmbda = 0.021377 + 5.3115e-6*re; ustar2 = uref2*xlmbda/8.;} else { xlmbda = 1/( 1.8*log(re)/log(10.)-1.64)^2; ustar2 = uref2*xlmbda/8.;} cmu = 0.09; kappa = 0.42; k = ustar2/sqrt(cmu); epsilon = ustar2^1.5/(kappa*dh*0.1); d2s3 = 2/3; r11 = d2s3*k; r22 = d2s3*k; r33 = d2s3*k; r12 = 0; r13 = 0; r23 = 0; """ req = [('r11', "Reynolds stress R11"), ('r22', "Reynolds stress R22"), ('r33', "Reynolds stress R33"), ('r12', "Reynolds stress R12"), ('r13', "Reynolds stress R13"), ('r23', "Reynolds stress R23"), ('epsilon', "turbulent dissipation")] sym = [('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'), ('t','time'), ('dt','time step'), ('iter','number of time step')] 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("slotFormulaTurb -> %s" % str(result)) self.__boundary.setTurbFormula(result) setGreenColor(self.pushButtonTurb, False) elif turb_model == 'Rij-EBRSM': exp = self.__boundary.getTurbFormula() if not exp: exp = self.__boundary.getDefaultTurbFormula(turb_model) exa = """#exemple : uref2 = 10.; dh = 0.2; re = sqrt(uref2)*dh*rho0/mu0; if (re < 2000){ # in this case u*^2 is directly calculated to not have a problem with # xlmbda=64/Re when Re->0 ustar2 = 8.*mu0*sqrt(uref2)/rho0/dh;} else if (re<4000){ xlmbda = 0.021377 + 5.3115e-6*re; ustar2 = uref2*xlmbda/8.;} else { xlmbda = 1/( 1.8*log(re)/log(10.)-1.64)^2; ustar2 = uref2*xlmbda/8.;} cmu = 0.09; kappa = 0.42; k = ustar2/sqrt(cmu); epsilon = ustar2^1.5/(kappa*dh*0.1); d2s3 = 2/3; r11 = d2s3*k; r22 = d2s3*k; r33 = d2s3*k; r12 = 0; r13 = 0; r23 = 0; alpha = 1.; """ req = [('r11', "Reynolds stress R11"), ('r22', "Reynolds stress R22"), ('r33', "Reynolds stress R33"), ('r12', "Reynolds stress R12"), ('r13', "Reynolds stress R13"), ('r23', "Reynolds stress R23"), ('epsilon', "turbulent dissipation"), ('alpha', "alpha")] sym = [('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'), ('t','time'), ('dt','time step'), ('iter','number of time step')] 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("slotFormulaTurb -> %s" % str(result)) self.__boundary.setTurbFormula(result) setGreenColor(self.pushButtonTurb, False) elif turb_model == 'v2f-BL-v2/k': exp = self.__boundary.getTurbFormula() if not exp: exp = self.__boundary.getDefaultTurbFormula(turb_model) exa = """#exemple : uref2 = 10.; dh = 0.2; re = sqrt(uref2)*dh*rho0/mu0; if (re < 2000){ # in this case u*^2 is directly calculated to not have a problem with # xlmbda=64/Re when Re->0 ustar2 = 8.*mu0*sqrt(uref2)/rho0/dh;} else if (re<4000){ xlmbda = 0.021377 + 5.3115e-6*re; ustar2 = uref2*xlmbda/8.;} else { xlmbda = 1/( 1.8*log(re)/log(10.)-1.64)^2; ustar2 = uref2*xlmbda/8.;} cmu = 0.09; kappa = 0.42; d2s3 = 2/3; k = ustar2/sqrt(cmu); epsilon = ustar2^1.5/(kappa*dh*0.1); phi = d2s3; alpha = 0;""" req = [('k', "turbulent energy"), ('epsilon', "turbulent dissipation"), ('phi', "variable phi in v2f model"), ('alpha', "variable alpha in v2f model")] sym = [('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'), ('t','time'), ('dt','time step'), ('iter','number of time step')] 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("slotFormulaTurb -> %s" % str(result)) self.__boundary.setTurbFormula(result) setGreenColor(self.pushButtonTurb, False) elif turb_model == 'k-omega-SST': exp = self.__boundary.getTurbFormula() if not exp: exp = self.__boundary.getDefaultTurbFormula(turb_model) exa = """#exemple : uref2 = 10.; dh = 0.2; re = sqrt(uref2)*dh*rho0/mu0; if (re < 2000){ # in this case u*^2 is directly calculated to not have a problem with # xlmbda=64/Re when Re->0 ustar2 = 8.*mu0*sqrt(uref2)/rho0/dh;} else if (re<4000){ xlmbda = 0.021377 + 5.3115e-6*re; ustar2 = uref2*xlmbda/8.;} else { xlmbda = 1/( 1.8*log(re)/log(10.)-1.64)^2; ustar2 = uref2*xlmbda/8.;} cmu = 0.09; kappa = 0.42; k = ustar2/sqrt(cmu); eps = ustar2^1.5/(kappa*dh*0.1); omega = eps/(cmu * k);""" req = [('k', "turbulent energy"), ('omega', "specific dissipation rate")] sym = [('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'), ('t','time'), ('dt','time step'), ('iter','number of time step')] 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("slotFormulaTurb -> %s" % str(result)) self.__boundary.setTurbFormula(result) setGreenColor(self.pushButtonTurb, False) elif turb_model == 'Spalart-Allmaras': exp = self.__boundary.getTurbFormula() if not exp: exp = self.__boundary.getDefaultTurbFormula(turb_model) exa = """#exemple : uref2 = 10.; dh = 0.2; re = sqrt(uref2)*dh*rho0/mu0; if (re < 2000){ # in this case u*^2 is directly calculated to not have a problem with # xlmbda=64/Re when Re->0 ustar2 = 8.*mu0*sqrt(uref2)/rho0/dh;} else if (re<4000){ xlmbda = 0.021377 + 5.3115e-6*re; ustar2 = uref2*xlmbda/8.;} else { xlmbda = 1/( 1.8*log(re)/log(10.)-1.64)^2; ustar2 = uref2*xlmbda/8.;} cmu = 0.09; kappa = 0.42; k = ustar2/sqrt(cmu); eps = ustar2^1.5/(kappa*dh*0.1); nu_tilda = eps/(cmu * k);""" req = [('nu_tilda', "nu_tilda")] sym = [('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'), ('t','time'), ('dt','time step'), ('iter','number of time step')] 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("slotFormulaTurb -> %s" % str(result)) self.__boundary.setTurbFormula(result) setGreenColor(self.pushButtonTurb, False) def tr(self, text): """ Translation """ return text
class LagrangianBoundariesView(QWidget, Ui_LagrangianBoundariesForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianBoundariesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = LagrangianBoundariesModel(self.case) self.modelBoundaries = StandardItemModelBoundaries( self.case, self.model) self.tableViewBoundaries.setModel(self.modelBoundaries) self.tableViewBoundaries.setAlternatingRowColors(True) if QT_API == "PYQT4": self.tableViewBoundaries.horizontalHeader().setResizeMode( QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewBoundaries.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) delegateInteraction = ParticleBoundaryInteractionDelegate( self.tableViewBoundaries) delegateSetNumber = ValueDelegate(self.tableViewBoundaries) self.tableViewBoundaries.setItemDelegateForColumn( 2, delegateInteraction) self.tableViewBoundaries.setItemDelegateForColumn(3, delegateSetNumber) self.modelIPOIT = ComboModel(self.comboBoxIPOIT, 3, 1) self.modelIPOIT.addItem(self.tr("Mass flow rate"), "rate") self.modelIPOIT.addItem(self.tr("Statistical weight set by values"), "prescribed") self.modelIJUVW = ComboModel(self.comboBoxIJUVW, 4, 1) self.modelIJUVW.addItem(self.tr("Fluid velocity"), "fluid") self.modelIJUVW.addItem(self.tr("Normal direction velocity"), "norm") self.modelIJUVW.addItem(self.tr("Velocity given by values"), "components") self.modelIJRTP = ComboModel(self.comboBoxIJRTP, 2, 1) self.modelIJRTP.addItem(self.tr("Fluid temperature"), "fluid") self.modelIJRTP.addItem(self.tr("Temperature set by values"), "prescribed") self.tableViewBoundaries.clicked[QModelIndex].connect( self.slotSelectBoundary) self.modelBoundaries.dataChanged.connect(self.dataChanged) self.spinBoxICLAS.valueChanged[int].connect(self.slotICLAS) self.lineEditIJNBP.textChanged[str].connect(self.slotIJNBP) self.lineEditIJFRE.textChanged[str].connect(self.slotIJFRE) self.lineEditICLST.textChanged[str].connect(self.slotICLST) self.lineEditIDEBT.textChanged[str].connect(self.slotIDEBT) self.comboBoxIPOIT.activated[str].connect(self.slotIPOITChoice) self.lineEditIPOIT.textChanged[str].connect(self.slotIPOIT) self.lineEditIROPT.textChanged[str].connect(self.slotIROPT) self.lineEditIRCOLM.textChanged[str].connect(self.slotIRCOLM) self.comboBoxIJUVW.activated[str].connect(self.slotIJUVW) self.lineEditIUNO.textChanged[str].connect(self.slotIUNO) self.lineEditIUPT.textChanged[str].connect(self.slotIUPT) self.lineEditIVPT.textChanged[str].connect(self.slotIVPT) self.lineEditIWPT.textChanged[str].connect(self.slotIWPT) self.comboBoxIJRTP.activated[str].connect(self.slotIJRTP) self.lineEditITPT.textChanged[str].connect(self.slotITPT) self.lineEditICPT.textChanged[str].connect(self.slotICPT) self.lineEditIEPSI.textChanged[str].connect(self.slotIEPSI) self.lineEditIDPT.textChanged[str].connect(self.slotIDPT) self.lineEditIVDPT.textChanged[str].connect(self.slotIVDPT) self.lineEditINUCHL.textChanged[str].connect(self.slotINUCHL) self.lineEditIHPT.textChanged[str].connect(self.slotIHPT) # Validators validatorIJNBP = IntValidator(self.lineEditIJNBP, min=0) validatorIJFRE = IntValidator(self.lineEditIJFRE, min=0) validatorICLST = IntValidator(self.lineEditICLST, min=0) validatorIDEBT = DoubleValidator(self.lineEditIDEBT, min=0.) validatorIPOIT = DoubleValidator(self.lineEditIPOIT, min=0.) validatorIPOIT.setExclusiveMin(True) validatorIROPT = DoubleValidator(self.lineEditIROPT, min=0.) validatorIROPT.setExclusiveMin(True) validatorIRCOLM = DoubleValidator(self.lineEditIRCOLM, min=0.) validatorIUNO = DoubleValidator(self.lineEditIUNO) validatorIUPT = DoubleValidator(self.lineEditIUPT) validatorIVPT = DoubleValidator(self.lineEditIVPT) validatorIWPT = DoubleValidator(self.lineEditIWPT) validatorITPT = DoubleValidator(self.lineEditITPT) validatorICPT = DoubleValidator(self.lineEditICPT) validatorIEPSI = DoubleValidator(self.lineEditIEPSI) validatorIDPT = DoubleValidator(self.lineEditIDPT, min=0.) validatorIVDPT = DoubleValidator(self.lineEditIVDPT) validatorINUCHL = IntValidator(self.lineEditINUCHL, min=0) validatorIHPT = DoubleValidator(self.lineEditIHPT) self.lineEditIJNBP.setValidator(validatorIJNBP) self.lineEditIJFRE.setValidator(validatorIJFRE) self.lineEditICLST.setValidator(validatorICLST) self.lineEditIDEBT.setValidator(validatorIDEBT) self.lineEditIPOIT.setValidator(validatorIPOIT) self.lineEditIROPT.setValidator(validatorIROPT) self.lineEditIRCOLM.setValidator(validatorIRCOLM) self.lineEditIUNO.setValidator(validatorIUNO) self.lineEditIUPT.setValidator(validatorIUPT) self.lineEditIVPT.setValidator(validatorIVPT) self.lineEditIWPT.setValidator(validatorIWPT) self.lineEditITPT.setValidator(validatorITPT) self.lineEditICPT.setValidator(validatorICPT) self.lineEditIEPSI.setValidator(validatorIEPSI) self.lineEditIDPT.setValidator(validatorIDPT) self.lineEditIVDPT.setValidator(validatorIVDPT) self.lineEditINUCHL.setValidator(validatorINUCHL) self.lineEditIHPT.setValidator(validatorIHPT) self._hideAllWidgets() self.case.undoStartGlobal() def _hideAllWidgets(self): self.groupBoxSetNumber.hide() self.groupBoxMain.hide() self.groupBoxRate.hide() self.groupBoxVelocity.hide() self.groupBoxTemperature.hide() self.groupBoxDiameter.hide() self.groupBoxCoal.hide() @pyqtSlot("QModelIndex") def slotSelectBoundary(self, index): """ """ self._hideAllWidgets() label, nature, interaction, n_sets = self.modelBoundaries.getItem( index.row()) self.label = label if interaction != "inlet": return self.model.setCurrentBoundaryNode(nature, label) if n_sets > 0: self.groupBoxSetNumber.show() self.spinBoxICLAS.setMinimum(1) self.spinBoxICLAS.setMaximum(n_sets) self.spinBoxICLAS.setValue(1) self.slotICLAS(1) def dataChanged(self, topLeft, bottomRight): """ """ self.slotSelectBoundary(topLeft) @pyqtSlot(int) def slotICLAS(self, iset): """ Input ICLAS. """ self.iset = iset index = self.tableViewBoundaries.currentIndex() label, nature, interaction, n_sets = self.modelBoundaries.getItem( index.row()) if interaction == "inlet": self.model.setCurrentSetNode(self.label, iset) self.LM = LagrangianModel(self.case) part_model = self.LM.getParticlesModel() # Main variables self.groupBoxMain.show() npart = self.model.getNumberOfParticulesInSetValue( self.label, self.iset) self.lineEditIJNBP.setText(str(npart)) freq = self.model.getInjectionFrequencyValue(self.label, self.iset) self.lineEditIJFRE.setText(str(freq)) self.LSM = LagrangianStatisticsModel(self.case) if self.LSM.getGroupOfParticlesValue() > 0: igroup = self.model.getParticleGroupNumberValue( self.label, self.iset) self.lineEditICLST.setText(str(igroup)) self.labelICLST.show() self.lineEditICLST.show() else: self.labelICLST.hide() self.lineEditICLST.hide() # Rate / stat. weight self.groupBoxRate.show() choice = self.model.getStatisticalWeightChoice(self.label, self.iset) self.modelIPOIT.setItem(str_model=choice) text = self.modelIPOIT.dicoM2V[choice] self.slotIPOITChoice(text) # Velocity self.groupBoxVelocity.show() choice = self.model.getVelocityChoice(self.label, self.iset) self.modelIJUVW.setItem(str_model=choice) text = self.modelIJUVW.dicoM2V[choice] self.slotIJUVW(text) # Fouling colm = self.model.getFoulingIndexValue(self.label, self.iset) self.lineEditIRCOLM.setText(str(colm)) # Temperature status = self.LM.getHeating() if part_model == "thermal" and status == "on": self.groupBoxTemperature.show() choice = self.model.getTemperatureChoice(self.label, self.iset) self.modelIJRTP.setItem(str_model=choice) text = self.modelIJRTP.dicoM2V[choice] self.slotIJRTP(text) cp = self.model.getSpecificHeatValue(self.label, self.iset) self.lineEditICPT.setText(str(cp)) eps = self.model.getEmissivityValue(self.label, self.iset) self.lineEditIEPSI.setText(str(eps)) # Coals if CoalCombustionModel( self.case).getCoalCombustionModel("only") != 'off': self.groupBoxCoal.show() icoal = self.model.getCoalNumberValue(self.label, self.iset) self.lineEditINUCHL.setText(str(icoal)) temp = self.model.getCoalTemperatureValue(self.label, self.iset) self.lineEditIHPT.setText(str(temp)) # Diameter self.groupBoxDiameter.show() diam = self.model.getDiameterValue(self.label, self.iset) vdiam = self.model.getDiameterVarianceValue(self.label, self.iset) self.lineEditIDPT.setText(str(diam)) self.lineEditIVDPT.setText(str(vdiam)) #Coal if CoalCombustionModel( self.case).getCoalCombustionModel("only") != 'off': self.labelIROPT.hide() self.labelUnitIROPT.hide() self.lineEditIROPT.hide()
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 FluidCharacteristicsView(QWidget, Ui_FluidCharacteristicsForm): """ Class to open Molecular Properties Page. """ density = """# Density of air density = 1.293*(273.15 / temperature); # density for mixtures of gases # # Y1 -> mass fraction of component 1 # Y2 -> mass fraction of component 2 rho1 = 1.25051; rho2 = 1.7832; A = (Y1 / rho1) + (Y2 /rho2); density = 1.0 / A; """ density_h = """# Density density = enthalpy / 1040. * 1.29; # density for mixtures of gases # # Y1 -> mass fraction of component 1 # Y2 -> mass fraction of component 2 rho1 = 1.25051; rho2 = 1.7832; A = (Y1 / rho1) + (Y2 /rho2); density = 1.0 / A; """ density_wo = """density = 1.25051; """ molecular_viscosity = """# Sutherland's Formula # Gas Cst T0 mu0 # air 120 291.15 18.27e-6 # nitrogen 111 300.55 17.81e-6 # oxygen 127 292.25 20.18e-6 # carbon dioxide 240 293.15 14.8e-6 # carbon monoxide 118 288.15 17.2e-6 # hydrogen 72 293.85 8.76e-6 # ammonia 370 293.15 9.82e-6 # sulfur dioxide 416 293.65 12.54e-6 # helium 79.4 273 19e-6 CST = 120; T0 = 291.15; mu_ref = 18.27e-6; if ( temperature > 0 && temperature < 555) { molecular_viscosity = mu_ref * ((T0+CST) / (temperature+CST)) * (temperature/T0)^(3./2.); } else { molecular_viscosity = -999.0; } """ molecular_viscosity_h = """CST = 120; T0 = 291.15; mu_ref = 18.27e-6; temperature = enthalpy / 1040.; if ( enthalpy > 0) { molecular_viscosity = mu_ref * (T0+CST / temperature+CST) * (temperature/T0)^(3./2.); } else { molecular_viscosity = -999.0; } """ molecular_viscosity_wo = """CST = 120; T0 = 291.15; mu_ref = 18.27e-6; molecular_viscosity = mu_ref * (T0+CST); """ specific_heat = """# specific heat for mixtures of gases # # Y1 -> mass fraction of component 1 # Y2 -> mass fraction of component 2 Cp1 = 520.3; Cp2 = 1040.0; specific_heat = Y1 * Cp1 + Y2 *Cp2; """ volume_viscosity = """# volume_viscosity """ thermal_conductivity = """# oxygen thermal_conductivity = 6.2e-5 * temperature + 8.1e-3; # nitrogen thermal_conductivity = 6.784141e-5 * temperature + 5.564317e-3; # hydrogen thermal_conductivity = 4.431e-4 * temperature + 5.334e-2; """ thermal_conductivity_h = """temperature = enthalpy / 1040.; thermal_conductivity = 6.2e-5 * temperature + 8.1e-3; """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_FluidCharacteristicsForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = FluidCharacteristicsModel(self.case) self.notebook = NotebookModel(self.case) self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() tsm = self.mdl.tsm # Particular Widget init. taking into account chosen fluid model mdl_atmo, mdl_joule, mdl_thermal, mdl_gas, mdl_coal, mdl_comp, mdl_hgn=\ self.mdl.getThermoPhysicalModel() # Combo models self.modelRho = ComboModel(self.comboBoxRho, 2, 1) self.modelMu = ComboModel(self.comboBoxMu, 2, 1) self.modelCp = ComboModel(self.comboBoxCp, 2, 1) self.modelAl = ComboModel(self.comboBoxAl, 2, 1) self.modelDiff = ComboModel(self.comboBoxDiff, 2, 1) self.modelNameDiff = ComboModel(self.comboBoxNameDiff, 1, 1) self.modelViscv0 = ComboModel(self.comboBoxViscv0, 3, 1) self.modelDiftl0 = ComboModel(self.comboBoxDiftl0, 3, 1) self.modelMaterial = ComboModel(self.comboBoxMaterial, 1, 1) self.modelMethod = ComboModel(self.comboBoxMethod, 1, 1) self.modelReference = ComboModel(self.comboBoxReference, 1, 1) if mdl_joule == 'off': self.modelRho.addItem(self.tr('constant'), 'constant') self.modelRho.addItem(self.tr('material law'), 'thermal_law') if mdl_atmo != 'off': self.modelRho.addItem(self.tr('predefined law'), 'predefined_law') elif mdl_hgn != "off": self.modelRho.addItem(self.tr('linear mixture law'), 'predefined_law') elif mdl_joule != 'off': self.modelRho.addItem(self.tr('predefined law'), 'predefined_law') elif mdl_comp != 'off': self.modelRho.addItem(self.tr('predefined law'), 'predefined_law') elif mdl_gas != 'off' or mdl_coal != 'off': self.modelRho.addItem(self.tr('predefined law'), 'predefined_law') self.modelRho.addItem(self.tr('user law'), 'user_law') if mdl_joule == 'off': self.modelMu.addItem(self.tr('constant'), 'constant') self.modelMu.addItem(self.tr('material law'), 'thermal_law') if mdl_joule != 'off': self.modelMu.addItem(self.tr('predefined law'), 'predefined_law') if mdl_hgn != "off": self.modelMu.addItem(self.tr('linear mixture law'), 'predefined_law') self.modelMu.addItem(self.tr('user law'), 'user_law') if mdl_joule == 'off': self.modelCp.addItem(self.tr('constant'), 'constant') self.modelCp.addItem(self.tr('material law'), 'thermal_law') if mdl_joule != 'off': self.modelCp.addItem(self.tr('predefined law'), 'predefined_law') self.modelCp.addItem(self.tr('user law'), 'user_law') if mdl_joule == 'off': self.modelAl.addItem(self.tr('constant'), 'constant') self.modelAl.addItem(self.tr('material law'), 'thermal_law') if mdl_joule != 'off': self.modelAl.addItem(self.tr('predefined law'), 'predefined_law') self.modelAl.addItem(self.tr('user law'), 'user_law') self.modelDiff.addItem(self.tr('constant'), 'constant') self.modelDiff.addItem(self.tr('user law'), 'user_law') self.modelViscv0.addItem(self.tr('constant'), 'constant') self.modelViscv0.addItem(self.tr('user law'), 'user_law') self.modelViscv0.addItem(self.tr('material law'), 'thermal_law') self.modelDiftl0.addItem(self.tr('constant'), 'constant') self.modelDiftl0.addItem(self.tr('user law'), 'user_law') self.modelDiftl0.addItem(self.tr('material law'), 'thermal_law') if mdl_gas != 'off' or mdl_coal != 'off': self.modelDiftl0.addItem(self.tr('predefined law'), 'predefined_law') self.scalar = "" scalar_list = self.mdl.m_sca.getUserScalarNameList() for s in self.mdl.m_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for scalar in scalar_list: self.modelNameDiff.addItem(scalar) # Validators validatorP0 = DoubleValidator(self.lineEditP0, min=0.0) self.lineEditP0.setValidator(validatorP0) validatorT0 = DoubleValidator(self.lineEditT0, min=0.0) validatorT0.setExclusiveMin(True) self.lineEditT0.setValidator(validatorT0) validatorOxydant = DoubleValidator(self.lineEditOxydant, min=0.0) validatorOxydant.setExclusiveMin(True) self.lineEditOxydant.setValidator(validatorOxydant) validatorFuel = DoubleValidator(self.lineEditFuel, min=0.0) validatorFuel.setExclusiveMin(True) self.lineEditFuel.setValidator(validatorFuel) validatorMM = DoubleValidator(self.lineEditMassMolar, min=0.0) validatorMM.setExclusiveMin(True) self.lineEditMassMolar.setValidator(validatorMM) validatorRho = DoubleValidator(self.lineEditRho, min=0.0) validatorRho1 = DoubleValidator(self.lineEditRho1, min=0.0) validatorRho2 = DoubleValidator(self.lineEditRho2, min=0.0) validatorMu = DoubleValidator(self.lineEditMu, min=0.0) validatorMu1 = DoubleValidator(self.lineEditMu1, min=0.0) validatorMu2 = DoubleValidator(self.lineEditMu2, min=0.0) validatorCp = DoubleValidator(self.lineEditCp, min=0.0) validatorAl = DoubleValidator(self.lineEditAl, min=0.0) validatorDiff = DoubleValidator(self.lineEditDiff, min=0.0) validatorViscv0 = DoubleValidator(self.lineEditViscv0, min=0.0) validatorDiftl0 = DoubleValidator(self.lineEditDiftl0, min=0.0) validatorRho.setExclusiveMin(True) validatorRho1.setExclusiveMin(True) validatorRho2.setExclusiveMin(True) validatorMu.setExclusiveMin(True) validatorMu1.setExclusiveMin(True) validatorMu2.setExclusiveMin(True) validatorCp.setExclusiveMin(True) validatorAl.setExclusiveMin(True) validatorDiff.setExclusiveMin(True) validatorDiftl0.setExclusiveMin(True) self.lineEditRho.setValidator(validatorRho) self.lineEditRho1.setValidator(validatorRho1) self.lineEditRho2.setValidator(validatorRho2) self.lineEditMu.setValidator(validatorMu) self.lineEditMu1.setValidator(validatorMu1) self.lineEditMu2.setValidator(validatorMu2) self.lineEditCp.setValidator(validatorCp) self.lineEditAl.setValidator(validatorAl) self.lineEditDiff.setValidator(validatorDiff) self.lineEditViscv0.setValidator(validatorViscv0) self.lineEditDiftl0.setValidator(validatorDiftl0) # Connections self.lineEditP0.textChanged[str].connect(self.slotPressure) self.lineEditT0.textChanged[str].connect(self.slotTemperature) self.lineEditOxydant.textChanged[str].connect(self.slotTempOxydant) self.lineEditFuel.textChanged[str].connect(self.slotTempFuel) self.lineEditMassMolar.textChanged[str].connect(self.slotMassemol) self.comboBoxRho.currentIndexChanged[str].connect(self.slotStateRho) self.comboBoxMu.currentIndexChanged[str].connect(self.slotStateMu) self.comboBoxCp.currentIndexChanged[str].connect(self.slotStateCp) self.comboBoxAl.currentIndexChanged[str].connect(self.slotStateAl) self.comboBoxDiff.currentIndexChanged[str].connect(self.slotStateDiff) self.comboBoxNameDiff.activated[str].connect(self.slotNameDiff) self.comboBoxViscv0.currentIndexChanged[str].connect( self.slotStateViscv0) self.comboBoxMaterial.activated[str].connect(self.slotMaterial) self.comboBoxMethod.activated[str].connect(self.slotMethod) self.comboBoxReference.activated[str].connect(self.slotReference) self.lineEditRho.textChanged[str].connect(self.slotRho) self.lineEditRho1.textChanged[str].connect(self.slotRho1) self.lineEditRho2.textChanged[str].connect(self.slotRho2) self.lineEditMu.textChanged[str].connect(self.slotMu) self.lineEditMu1.textChanged[str].connect(self.slotMu1) self.lineEditMu2.textChanged[str].connect(self.slotMu2) self.lineEditCp.textChanged[str].connect(self.slotCp) self.lineEditAl.textChanged[str].connect(self.slotAl) self.lineEditDiff.textChanged[str].connect(self.slotDiff) self.lineEditDiftl0.textChanged[str].connect(self.slotDiftl0) self.lineEditViscv0.textChanged[str].connect(self.slotViscv0) self.pushButtonRho.clicked.connect(self.slotFormulaRho) self.pushButtonMu.clicked.connect(self.slotFormulaMu) self.pushButtonCp.clicked.connect(self.slotFormulaCp) self.pushButtonAl.clicked.connect(self.slotFormulaAl) self.pushButtonDiff.clicked.connect(self.slotFormulaDiff) self.pushButtonViscv0.clicked.connect(self.slotFormulaViscv0) self.initializeWidget() self.case.undoStartGlobal() def initializeWidget(self): """ """ mdls = self.mdl.getThermoPhysicalModel() mdl_atmo, mdl_joule, mdl_thermal, mdl_gas, mdl_coal, mdl_comp, mdl_hgn = mdls self.groupBoxMassMolar.hide() if mdl_atmo != "off": self.labelInfoT0.hide() elif mdl_comp != "off" or mdl_coal != "off": m = self.mdl.getMassemol() self.lineEditMassMolar.setText(str(m)) self.groupBoxMassMolar.show() if mdl_thermal != "off" or mdl_gas == 'd3p': t = self.mdl.getTemperature() self.lineEditT0.setText(str(t)) if mdl_thermal == "temperature_celsius": self.labelUnitT0.setText("\xB0 C") if self.mdl.getMaterials() != "user_material": self.labelInfoT0.hide() else: self.groupBoxTemperature.hide() if mdl_gas == 'd3p': self.groupBoxTempd3p.show() t_oxy = self.mdl.getTempOxydant() t_fuel = self.mdl.getTempFuel() self.lineEditOxydant.setText(str(t_oxy)) self.lineEditFuel.setText(str(t_fuel)) else: self.groupBoxTempd3p.hide() darc = GroundwaterModel(self.case).getGroundwaterModel() if darc != 'off': self.groupBoxPressure.hide() else: p = self.mdl.getPressure() self.lineEditP0.setText(str(p)) if self.mdl.tables == 0 or mdl_joule != 'off' or mdl_comp != 'off': self.groupBoxTableChoice.hide() else: self.groupBoxTableChoice.show() fluids = self.mdl.getLibPropertiesDict() o_keys = list(fluids.keys()) # for Python2/3 compatibility # fluids.keys() ordered and iteratable # already in Python3 o_keys.sort() for f in o_keys: if fluids[f] != 0: self.modelMaterial.addItem(self.tr(f), f) else: self.modelMaterial.addItem(self.tr(f), True) material = self.mdl.getMaterials() self.modelMaterial.setItem(str_model=material) self.updateMethod() # VoF if mdl_hgn != 'off': self.widgetRefRho.hide() self.widgetVofRho.show() self.widgetRefMu.hide() self.widgetVofMu.show() else: self.widgetRefRho.show() self.widgetVofRho.hide() self.widgetRefMu.show() self.widgetVofMu.hide() # compressible self.groupBoxViscv0.hide() # combustion self.groupBoxDiftl0.hide() if self.scalar == "": self.groupBoxDiff.hide() else: self.groupBoxDiff.show() self.lineEditDiff.setText( str( self.mdl.m_sca.getScalarDiffusivityInitialValue( self.scalar))) diff_choice = self.mdl.m_sca.getScalarDiffusivityChoice( self.scalar) self.modelDiff.setItem(str_model=diff_choice) self.modelNameDiff.setItem(str_model=str(self.scalar)) if diff_choice != 'user_law': self.pushButtonDiff.hide() self.pushButtonDiff.setEnabled(False) self.pushButtonDiff.setStyleSheet("background-color: None") else: self.pushButtonDiff.show() self.pushButtonDiff.setEnabled(True) name = self.mdl.m_sca.getScalarDiffusivityName(self.scalar) exp = self.mdl.m_sca.getDiffFormula(self.scalar) if exp: self.pushButtonDiff.setStyleSheet( "background-color: green") self.pushButtonDiff.setToolTip(exp) else: self.pushButtonDiff.setStyleSheet("background-color: red") # Standard Widget initialization for tag, symbol in self.mdl.lst: __model = getattr(self, "model" + symbol) __line = getattr(self, "lineEdit" + symbol) __button = getattr(self, "pushButton" + symbol) __label = getattr(self, "label" + symbol) __labelu = getattr(self, "labelUnit" + symbol) if tag != 'dynamic_diffusion': __labelv = getattr(self, "labelVar" + symbol) c = self.mdl.getPropertyMode(tag) if c not in __model.getItems(): c = 'constant' self.mdl.setPropertyMode(tag, c) __model.setItem(str_model=c) if c == 'user_law': __button.show() __button.setEnabled(True) __label.setText(self.tr("Reference value")) else: __button.hide() __button.setEnabled(False) __label.setText(self.tr("Reference value")) if c == 'thermal_law': __line.hide() __label.hide() __labelu.hide() __labelv.hide() else: __line.show() __label.show() __labelu.show() __labelv.show() try: if self.mdl.getMaterials() == "user_material": __model.disableItem(str_model='thermal_law') else: __model.enableItem(str_model='thermal_law') except Exception: pass else: __label.setText(self.tr("Reference value")) __line.setText(str(self.mdl.getInitialValue(tag))) # If no thermal scalar, hide specific heat and thermal conductivity. if mdl_thermal == 'off': self.groupBoxCp.hide() self.groupBoxAl.hide() if mdl_gas != 'off' or mdl_coal != 'off': self.groupBoxDiftl0.show() for tag, symbol in self.mdl.lst: __model = getattr(self, "model" + symbol) __line = getattr(self, "lineEdit" + symbol) __button = getattr(self, "pushButton" + symbol) __label = getattr(self, "label" + symbol) __combo = getattr(self, "comboBox" + symbol) # Gas or coal combustion if mdl_gas != 'off' or mdl_coal != 'off': if tag == 'density': __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() self.mdl.setPropertyMode(tag, 'predefined_law') __label.setText( self.tr("Calculation by\n perfect gas law")) __line.setText(str("")) __line.setEnabled(False) elif tag == 'dynamic_diffusion': __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() else: __model.setItem(str_model='constant') self.mdl.setPropertyMode(tag, 'constant') # Joule if mdl_joule == 'arc': __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() self.mdl.setPropertyMode(tag, 'predefined_law') # Atmospheric Flows if mdl_atmo != 'off': if tag == 'density': __model.disableItem(str_model='constant') __model.disableItem(str_model='predefined_law') __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() # VoF if mdl_hgn != 'off': if tag == 'molecular_viscosity' or tag == 'density': __model.disableItem(str_model='constant') __model.disableItem(str_model='predefined_law') __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() # Compressible Flows if mdl_comp != 'off': self.groupBoxViscv0.show() if tag == 'density': __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() self.mdl.setPropertyMode(tag, 'predefined_law') __line.setEnabled(True) if tag == 'specific_heat': __model.setItem(str_model='constant') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() self.mdl.setPropertyMode(tag, 'constant') self.groupBoxCp.setTitle('Isobaric specific heat') if tag == 'volume_viscosity': __combo.setEnabled(True) c = self.mdl.getPropertyMode(tag) if c == 'user_law': __button.setEnabled(True) else: __button.setEnabled(False) else: if tag == 'specific_heat': self.groupBoxCp.setTitle('Specific heat') if mdl_hgn != 'off': self.lineEditRho1.setText(str(self.mdl.getVofValueDensity(0))) self.lineEditRho2.setText(str(self.mdl.getVofValueDensity(1))) self.lineEditMu1.setText(str(self.mdl.getVofValueViscosity(0))) self.lineEditMu2.setText(str(self.mdl.getVofValueViscosity(1))) def updateTypeChoice(self, old_choice): """ add/suppress thermo tables for each properties """ for tag, symbol in self.mdl.lst: __model = getattr(self, "model" + symbol) if self.mdl.getMaterials() == "user_material": __model.disableItem(str_model='thermal_law') else: __model.enableItem(str_model='thermal_law') if old_choice == "user_material": self.mdl.setPropertyMode(tag, 'thermal_law') self.__changeChoice(str("material law"), symbol, tag) c = self.mdl.getPropertyMode(tag) __model.setItem(str_model=c) def updateMethod(self): """ update method list with material choice """ for nb in range(len(self.modelMethod.getItems())): self.modelMethod.delItem(0) material = self.mdl.getMaterials() method = self.mdl.getMethod() have_method = False methods = self.mdl.getLibPropertyMethods(material) for m in methods: if method == m[0]: have_method = True self.modelMethod.addItem(self.tr(m[0]), m[0], not m[1]) # current method not in list, add it with warning if not have_method: self.modelMethod.addItem(self.tr(method), method, True) # update comboBoxMethod self.modelMethod.setItem(str_model=method) self.mdl.setMethod(method) self.updateReference(material, method) def updateReference(self, material, method): """ update method list with material choice """ self.comboBoxReference.hide() self.labelReference.hide() for nb in range(len(self.modelReference.getItems())): self.modelReference.delItem(0) reference = self.mdl.getReference() references = self.mdl.getAvailReferences(material, method) have_reference = False if references: for r in references: if reference == r: have_reference = True self.modelReference.addItem(self.tr(r), r) self.comboBoxReference.show() self.labelReference.show() if not have_reference: reference = references[0] self.modelReference.setItem(str_model=reference) self.mdl.setReference(reference) @pyqtSlot(str) def slotPressure(self, text): """ Input PRESS. """ if self.lineEditP0.validator().state == QValidator.Acceptable: p = from_qvariant(text, float) self.mdl.setPressure(p) @pyqtSlot(str) def slotTemperature(self, text): """ Input TEMPERATURE. """ if self.lineEditT0.validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.mdl.setTemperature(t) @pyqtSlot(str) def slotTempOxydant(self, text): """ Input oxydant TEMPERATURE. """ if self.lineEditOxydant.validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.mdl.setTempOxydant(t) @pyqtSlot(str) def slotTempFuel(self, text): """ Input fuel TEMPERATURE. """ if self.lineEditFuel.validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.mdl.setTempFuel(t) @pyqtSlot(str) def slotMassemol(self, text): """ Input Mass molar. """ if self.lineEditMassMolar.validator().state == QValidator.Acceptable: m = from_qvariant(text, float) self.mdl.setMassemol(m) @pyqtSlot(str) def slotMaterial(self, text): """ Method to call 'setMaterial' """ choice = self.modelMaterial.dicoV2M[str(text)] old_choice = self.mdl.getMaterials() self.mdl.setMaterials(choice) self.updateMethod() self.updateTypeChoice(old_choice) @pyqtSlot(str) def slotMethod(self, text): """ Method to call 'setMethod' """ choice = self.modelMethod.dicoV2M[str(text)] self.mdl.setMethod(choice) self.updateReference(self.mdl.getMaterials(), choice) @pyqtSlot(str) def slotReference(self, text): """ Method to call 'setReference' """ choice = self.modelReference.dicoV2M[str(text)] self.mdl.setReference(choice) @pyqtSlot(str) def slotStateRho(self, text): """ Method to call 'getState' with correct arguements for 'rho' """ self.__changeChoice(str(text), 'Rho', 'density') @pyqtSlot(str) def slotStateMu(self, text): """ Method to call 'getState' with correct arguements for 'Mu' """ self.__changeChoice(str(text), 'Mu', 'molecular_viscosity') @pyqtSlot(str) def slotStateCp(self, text): """ Method to call 'getState' with correct arguements for 'Cp' """ self.__changeChoice(str(text), 'Cp', 'specific_heat') @pyqtSlot(str) def slotStateViscv0(self, text): """ Method to call 'getState' with correct arguements for 'Viscv0' """ self.__changeChoice(str(text), 'Viscv0', 'volume_viscosity') @pyqtSlot(str) def slotStateAl(self, text): """ Method to call 'getState' with correct arguements for 'Al' """ self.__changeChoice(str(text), 'Al', 'thermal_conductivity') @pyqtSlot(str) def slotStateDiff(self, text): """ Method to set diffusion choice for the coefficient """ choice = self.modelDiff.dicoV2M[str(text)] log.debug("slotStateDiff -> %s" % (text)) if choice != 'user_law': self.pushButtonDiff.setEnabled(False) self.pushButtonDiff.setStyleSheet("background-color: None") self.pushButtonDiff.hide() else: self.pushButtonDiff.show() self.pushButtonDiff.setEnabled(True) name = self.mdl.m_sca.getScalarDiffusivityName(self.scalar) exp = self.mdl.m_sca.getDiffFormula(self.scalar) if exp: self.pushButtonDiff.setStyleSheet("background-color: green") self.pushButtonDiff.setToolTip(exp) else: self.pushButtonDiff.setStyleSheet("background-color: red") self.mdl.m_sca.setScalarDiffusivityChoice(self.scalar, choice) @pyqtSlot(str) def slotNameDiff(self, text): """ Method to set the variance scalar choosed """ choice = self.modelNameDiff.dicoV2M[str(text)] log.debug("slotStateDiff -> %s" % (text)) self.scalar = str(text) self.lineEditDiff.setText( str(self.mdl.m_sca.getScalarDiffusivityInitialValue(self.scalar))) mdl = self.mdl.m_sca.getScalarDiffusivityChoice(self.scalar) self.modelDiff.setItem(str_model=mdl) if mdl != 'user_law': self.pushButtonDiff.hide() self.pushButtonDiff.setEnabled(False) self.pushButtonDiff.setStyleSheet("background-color: None") else: self.pushButtonDiff.show() self.pushButtonDiff.setEnabled(True) name = self.mdl.m_sca.getScalarDiffusivityName(self.scalar) exp = self.mdl.m_sca.getDiffFormula(self.scalar) if exp: self.pushButtonDiff.setStyleSheet("background-color: green") self.pushButtonDiff.setToolTip(exp) else: self.pushButtonDiff.setStyleSheet("background-color: red") def __changeChoice(self, text, sym, tag): """ Input variable state """ __model = getattr(self, "model" + sym) __line = getattr(self, "lineEdit" + sym) __combo = getattr(self, "comboBox" + sym) __label = getattr(self, "label" + sym) __button = getattr(self, "pushButton" + sym) __labelu = getattr(self, "labelUnit" + sym) __labelv = getattr(self, "labelVar" + sym) choice = __model.dicoV2M[text] log.debug("__changeChoice -> %s, %s" % (text, choice)) if choice != 'user_law': __button.hide() __button.setEnabled(False) __button.setStyleSheet("background-color: None") else: __button.setEnabled(True) __button.show() exp = None if sym == "Rho": exp = self.mdl.getFormula('density') elif sym == "Mu": exp = self.mdl.getFormula('molecular_viscosity') elif sym == "Cp": exp = self.mdl.getFormula('specific_heat') elif sym == "Viscv0": exp = self.mdl.getFormula('volume_viscosity') elif sym == "Al": exp = self.mdl.getFormula('thermal_conductivity') elif sym == "Diff": name = self.mdl.m_sca.getScalarDiffusivityName(self.scalar) exp = self.mdl.m_sca.getDiffFormula(self.scalar) if exp: __button.setStyleSheet("background-color: green") __button.setToolTip(exp) else: __button.setStyleSheet("background-color: red") if choice == 'thermal_law': __line.hide() __label.hide() __labelu.hide() __labelv.hide() else: __line.show() __label.show() __labelu.show() __labelv.show() self.mdl.setPropertyMode(tag, choice) @pyqtSlot(str) def slotRho(self, text): """ Update the density """ if self.lineEditRho.validator().state == QValidator.Acceptable: rho = from_qvariant(text, float) self.mdl.setInitialValueDensity(rho) @pyqtSlot(str) def slotRho1(self, text): """ Update the density of fluid 1 for VoF module """ if self.lineEditRho1.validator().state == QValidator.Acceptable: rho = from_qvariant(text, float) self.mdl.setVofValueDensity(0, rho) @pyqtSlot(str) def slotRho2(self, text): """ Update the density of fluid 2 for VoF module """ if self.lineEditRho2.validator().state == QValidator.Acceptable: rho = from_qvariant(text, float) self.mdl.setVofValueDensity(1, rho) @pyqtSlot(str) def slotMu(self, text): """ Update the molecular viscosity """ if self.lineEditMu.validator().state == QValidator.Acceptable: mu = from_qvariant(text, float) self.mdl.setInitialValueViscosity(mu) @pyqtSlot(str) def slotMu1(self, text): """ Update the molecular viscosity """ if self.lineEditMu1.validator().state == QValidator.Acceptable: mu = from_qvariant(text, float) self.mdl.setVofValueViscosity(0, mu) @pyqtSlot(str) def slotMu2(self, text): """ Update the molecular viscosity """ if self.lineEditMu2.validator().state == QValidator.Acceptable: mu = from_qvariant(text, float) self.mdl.setVofValueViscosity(1, mu) @pyqtSlot(str) def slotCp(self, text): """ Update the specific heat """ if self.lineEditCp.validator().state == QValidator.Acceptable: cp = from_qvariant(text, float) self.mdl.setInitialValueHeat(cp) @pyqtSlot(str) def slotViscv0(self, text): """ Update the volumic viscosity """ if self.lineEditViscv0.validator().state == QValidator.Acceptable: viscv0 = from_qvariant(text, float) self.mdl.setInitialValueVolumeViscosity(viscv0) @pyqtSlot(str) def slotAl(self, text): """ Update the thermal conductivity """ if self.lineEditAl.validator().state == QValidator.Acceptable: al = from_qvariant(text, float) self.mdl.setInitialValueCond(al) @pyqtSlot(str) def slotDiftl0(self, text): """ Update the thermal conductivity """ if self.lineEditDiftl0.validator().state == QValidator.Acceptable: diftl0 = from_qvariant(text, float) self.mdl.setInitialValueDyn(diftl0) @pyqtSlot(str) def slotDiff(self, text): """ Update the thermal conductivity """ if self.lineEditDiff.validator().state == QValidator.Acceptable: diff = from_qvariant(text, float) self.mdl.m_sca.setScalarDiffusivityInitialValue(self.scalar, diff) @pyqtSlot() def slotFormulaRho(self): """ User formula for density """ exp, req, sca, symbols_rho = self.mdl.getFormulaRhoComponents() self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "off": exa = FluidCharacteristicsView.density_wo elif mdl == "temperature_celsius": TempInContext = "(" + s + " + 273.15)" exa = FluidCharacteristicsView.density.replace( "temperature", TempInContext) elif mdl == "enthalpy": exa = FluidCharacteristicsView.density_h else: exa = FluidCharacteristicsView.density dialog = QMegEditorView(parent=self, function_type='vol', zone_name='all_cells', variable_name='density', expression=exp, required=req, symbols=symbols_rho, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaRho -> %s" % str(result)) self.mdl.setFormula('density', str(result)) self.pushButtonRho.setToolTip(result) self.pushButtonRho.setStyleSheet("background-color: green") @pyqtSlot() def slotFormulaMu(self): """ User formula for molecular viscosity """ exp, req, sca, symbols_mu = self.mdl.getFormulaMuComponents() self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "off": exa = FluidCharacteristicsView.molecular_viscosity_wo elif mdl == "temperature_celsius": TempInContext = "(" + s + " + 273.15)" exa = FluidCharacteristicsView.molecular_viscosity.replace( "temperature", TempInContext) elif mdl == "enthalpy": exa = FluidCharacteristicsView.molecular_viscosity_h else: exa = FluidCharacteristicsView.molecular_viscosity dialog = QMegEditorView(parent=self, function_type='vol', zone_name='all_cells', variable_name='molecular_viscosity', expression=exp, required=req, symbols=symbols_mu, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMu -> %s" % str(result)) self.mdl.setFormula('molecular_viscosity', str(result)) self.pushButtonMu.setToolTip(result) self.pushButtonMu.setStyleSheet("background-color: green") @pyqtSlot() def slotFormulaCp(self): """ User formula for specific heat """ exp, req, sca, symbols_cp = self.mdl.getFormulaCpComponents() exa = FluidCharacteristicsView.specific_heat dialog = QMegEditorView(parent=self, function_type='vol', zone_name='all_cells', variable_name='specific_heat', expression=exp, required=req, symbols=symbols_cp, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaRho -> %s" % str(result)) self.mdl.setFormula('specific_heat', str(result)) self.pushButtonCp.setToolTip(result) self.pushButtonCp.setStyleSheet("background-color: green") @pyqtSlot() def slotFormulaViscv0(self): """ User formula for volumic viscosity """ exp, req, sca, symbols_viscv0 = self.mdl.getFormulaViscv0Components() exa = FluidCharacteristicsView.volume_viscosity dialog = QMegEditorView(parent=self, function_type='vol', zone_name='all_cells', variable_name='volume_viscosity', expression=exp, required=req, symbols=symbols_viscv0, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaViscv0 -> %s" % str(result)) self.mdl.setFormula('volume_viscosity', str(result)) self.pushButtonViscv0.setToolTip(result) self.pushButtonViscv0.setStyleSheet("background-color: green") @pyqtSlot() def slotFormulaAl(self): """ User formula for thermal conductivity """ exp, req, sca, symbols_al = self.mdl.getFormulaAlComponents() self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "temperature_celsius": TempInContext = "(" + s + " + 273.15)" exa = FluidCharacteristicsView.thermal_conductivity.replace( "temperature", TempInContext) elif mdl == "enthalpy": exa = FluidCharacteristicsView.thermal_conductivity_h else: exa = FluidCharacteristicsView.thermal_conductivity dialog = QMegEditorView(parent=self, function_type='vol', zone_name='all_cells', variable_name='thermal_conductivity', expression=exp, required=req, symbols=symbols_al, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaAl -> %s" % str(result)) self.mdl.setFormula('thermal_conductivity', str(result)) self.pushButtonAl.setToolTip(result) self.pushButtonAl.setStyleSheet("background-color: green") @pyqtSlot() def slotFormulaDiff(self): """ User formula for the diffusion coefficient """ exp, req, sca, sym = self.mdl.getFormulaDiffComponents(self.scalar) exa = '' dname = self.mdl.m_sca.getScalarDiffusivityName(self.scalar) dialog = QMegEditorView(parent=self, function_type='vol', zone_name='all_cells', variable_name=dname, expression=exp, required=req, symbols=sym, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaDiff -> %s" % str(result)) self.mdl.m_sca.setDiffFormula(self.scalar, str(result)) self.pushButtonDiff.setToolTip(result) self.pushButtonDiff.setStyleSheet("background-color: green")
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 SolidView(QWidget, Ui_Solid): """ Particles interaction layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_Solid.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = SolidModel(self.case) if self.mdl.getSolidFieldIdList() == []: self.groupBoxField.hide() self.groupBoxInteractions.hide() self.groupBoxGeneral.hide() self.labelNoParticles.show() return # Combo box models self.modelField = ComboModel(self.comboBoxField, 1, 1) for fieldId in self.mdl.getSolidFieldIdList(): label = self.mdl.getLabel(fieldId) name = str(fieldId) self.modelField.addItem(self.tr(label), name) self.currentid = -1 if len(self.mdl.getSolidFieldIdList()) > 0 : self.currentid = self.mdl.getSolidFieldIdList()[0] self.modelField.setItem(str_model = self.currentid) self.modelFriction = ComboModel(self.comboBoxFriction, 3, 1) self.modelFriction.addItem(self.tr("none"), "none") self.modelFriction.addItem(self.tr("pressure"), "pressure") self.modelFriction.addItem(self.tr("fluxes"), "fluxes") self.modelGranular = ComboModel(self.comboBoxGranular, 3, 1) self.modelGranular.addItem(self.tr("none"), "none") self.modelGranular.addItem(self.tr("pressure"), "pressure") self.modelGranular.addItem(self.tr("fluxes"), "fluxes") self.modelKinetic = ComboModel(self.comboBoxKinetic, 3, 1) self.modelKinetic.addItem(self.tr("none"), "none") self.modelKinetic.addItem(self.tr("uncorrelated collision"), "uncorrelate_collision") self.modelKinetic.addItem(self.tr("correlated collision"), "correlate_collision") # Validators validatorComp = DoubleValidator(self.lineEditCompaction, min = 0.0) validatorComp.setExclusiveMin(True) self.lineEditCompaction.setValidator(validatorComp) # Connect signals to slots self.comboBoxField.activated[str].connect(self.slotField) self.comboBoxFriction.activated[str].connect(self.slotFriction) self.comboBoxGranular.activated[str].connect(self.slotGranular) self.comboBoxKinetic.activated[str].connect(self.slotKinetic) self.lineEditCompaction.textChanged[str].connect(self.slotCompaction) self.checkBoxCoupling.clicked[bool].connect(self.slotCoupling) # 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) @pyqtSlot(str) def slotFriction(self, text): """ INPUT type for choice of friction model """ model = self.modelFriction.dicoV2M[text] self.mdl.setFrictionModel(self.currentid, model) @pyqtSlot(str) def slotGranular(self, text): """ INPUT type for choice of granular model """ model = self.modelGranular.dicoV2M[text] self.mdl.setGranularModel(self.currentid, model) @pyqtSlot(str) def slotKinetic(self, text): """ INPUT type for choice of kinetic model """ model = self.modelKinetic.dicoV2M[text] self.mdl.setKineticModel(self.currentid, model) @pyqtSlot(str) def slotCompaction(self, var): """ """ if self.lineEditCompaction.validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.mdl.setCompaction(value) def initializeVariables(self, fieldId): """ Initialize variables when a new fieldId is choosen """ self.labelNoParticles.hide() value = self.mdl.getCompaction() self.lineEditCompaction.setText(str(value)) model = self.mdl.getFrictionModel(fieldId) self.modelFriction.setItem(str_model=model) model = self.mdl.getGranularModel(fieldId) self.modelGranular.setItem(str_model=model) model = self.mdl.getKineticModel(fieldId) self.modelKinetic.setItem(str_model = model) if self.mdl.getTurbulenceModel(fieldId) == "q2-q12" : self.labelCoupling.show() self.checkBoxCoupling.show() isCoupling = self.mdl.getCouplingStatus(fieldId) == "on" self.checkBoxCoupling.setChecked(isCoupling) else : self.labelCoupling.hide() self.checkBoxCoupling.hide() @pyqtSlot(bool) def slotCoupling(self, checked): """ check box for polydispersed coupling """ status = 'off' if checked: status = 'on' self.mdl.setCouplingStatus(self.currentid, status)
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) # Create the Page layout. # Model and QTreeView for Head Losses self.modelPorosity = StandardItemModelPorosity() self.treeView.setModel(self.modelPorosity) # Combo model self.modelPorosityType = ComboModel(self.comboBoxType, 2, 1) self.modelPorosityType.addItem(self.tr("isotropic"), 'isotropic') self.modelPorosityType.addItem(self.tr("anisotropic"), 'anisotropic') # Connections self.connect(self.treeView, SIGNAL("clicked(const QModelIndex &)"), self.slotSelectPorosityZones) self.connect(self.comboBoxType, SIGNAL("activated(const QString&)"), self.slotPorosity) self.connect(self.pushButtonPorosity, SIGNAL("clicked()"), 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() @pyqtSignature("const 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) setGreenColor(self.pushButtonPorosity, True) self.entriesNumber = index.row() def forgetStandardWindows(self): """ For forget standard windows """ self.groupBoxType.hide() self.groupBoxDef.hide() @pyqtSignature("const QString &") 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) @pyqtSignature("") 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')] 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, result) setGreenColor(self.sender(), False) def tr(self, text): """ Translation """ return text