示例#1
0
    def setup(self, case):

        self.case = case

        self.case.undoStopGlobal()

        self.__model = ConjugateHeatTransferModel(self.case)

        # Models
        self.modelSyrthes = StandardItemModelSyrthes(self.__model)
        self.tableViewSyrthes.setModel(self.modelSyrthes)

        if QT_API == "PYQT4":
            self.tableViewSyrthes.verticalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewSyrthes.horizontalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewSyrthes.horizontalHeader().setResizeMode(
                1, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewSyrthes.verticalHeader().setSectionResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewSyrthes.horizontalHeader().setSectionResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewSyrthes.horizontalHeader().setSectionResizeMode(
                1, QHeaderView.Stretch)

        self.modelProjectionAxis = ComboModel(self.comboBoxProjectionAxis, 1,
                                              1)
        self.modelProjectionAxis.addItem("off")
        self.modelProjectionAxis.addItem("x")
        self.modelProjectionAxis.addItem("y")
        self.modelProjectionAxis.addItem("z")

        # connections
        self.comboBoxProjectionAxis.currentTextChanged[str].connect(
            self.slotProjectionAxis)
        self.lineEditVerbosity.textChanged[str].connect(self.slotVerbosity)
        self.lineEditVisualization.textChanged[str].connect(
            self.slotVisualization)
        self.lineEditTolerance.editingFinished.connect(self.slotTolerance)
        self.lineEditVerbosity.setValidator(
            IntValidator(self.lineEditVerbosity))
        self.lineEditVisualization.setValidator(
            IntValidator(self.lineEditVisualization))

        _tolValidator = DoubleValidator(self.lineEditTolerance, min=0.)
        _tolValidator.setExclusiveMin()
        self.lineEditTolerance.setValidator(_tolValidator)

        self.initializeParameters()

        self.case.undoStartGlobal()
    def __addValidators(self):
        """
        Add the validator for NALIMX and EPALIM
        """
        validatorNALIMX = IntValidator(self.lineEditNALIMX, min=1)
        self.lineEditNALIMX.setValidator(validatorNALIMX)

        validatorEPALIM = DoubleValidator(self.lineEditEPALIM, min=0.0)
        validatorEPALIM.setExclusiveMin(True)
        self.lineEditEPALIM.setValidator(validatorEPALIM)
示例#3
0
 def createEditor(self, parent, option, index):
     row = index.row()
     stype = index.model().getData(row, 2)
     editor = QLineEdit(parent)
     if stype == 'time step':
         validator = IntValidator(editor, min=1)
     else:
         validator = DoubleValidator(editor, min=0.)
     editor.setValidator(validator)
     return editor
 def _setValidators(self):
     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)
 def createEditor(self, parent, option, index):
     editor = QLineEdit(parent)
     if index.column() == 3:
         validator = DoubleValidator(editor, min=0., max=0.01)
         validator.setExclusiveMin(True)
     elif (index.column() == 2 or index.column() == 4):
         validator = IntValidator(editor, min=1)
     elif index.column() == 5:
         validator = DoubleValidator(editor, min=0.)
         validator.setExclusiveMin(True)
     editor.setValidator(validator)
     editor.installEventFilter(self)
     return editor
    def __init__(self, parent, default):
        """
        Constructor
        """
        QDialog.__init__(self, parent)

        Ui_BatchRunningStopByIterationDialogForm.__init__(self)
        self.setupUi(self)

        self.setWindowTitle(self.tr("Stop"))

        self.default = default
        self.result = self.default.copy()

        v = IntValidator(self.lineEditStopIter, min=1)
        v.setExclusiveMin(True)
        self.lineEditStopIter.setValidator(v)

        # Previous values
        self.iter = self.default['iter']
        self.lineEditStopIter.setText(str(self.iter))

        self.lineEditStopIter.textChanged[str].connect(self.__slotStopIter)
    def __init__(self, parent, default):
        """
        Constructor
        """
        QDialog.__init__(self, parent)

        Ui_CommandMgrLinesDisplayedDialogForm.__init__(self)
        self.setupUi(self)

        self.setWindowTitle(self.tr("Number of lines displayed"))

        self.default = default
        self.result = self.default.copy()

        v = IntValidator(self.lineEditLines, min=0)
        self.lineEditLines.setValidator(v)

        # Previous values
        self.lines = self.default['lines']
        self.lineEditLines.setText(str(self.lines))

        self.lineEditLines.textChanged[str].connect(self.__slotLines)
        self.pushButtonLines.clicked.connect(self.__slotUnlimited)
示例#8
0
class TimeStepView(QWidget, Ui_TimeStepForm):
    """
    """
    def __init__(self, parent, case, tree):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_TimeStepForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = TimeStepModel(self.case)
        self.browser = tree

        # Check if xml contains deprecated steady algorithme
        has_deprecated_steady = False
        if str(self.mdl.getTimePassing()) == '-1':
            has_deprecated_steady = True

    # Combo model
        if has_deprecated_steady:
            self.modelTimeOptions = ComboModel(self.comboBoxOptions, 4, 1)
        else:
            self.modelTimeOptions = ComboModel(self.comboBoxOptions, 3, 1)
        self.modelTimeOptions.addItem(self.tr("Constant"), '0')
        self.modelTimeOptions.addItem(self.tr("Time varying (adaptive)"), '1')
        self.modelTimeOptions.addItem(self.tr("Steady (local time step)"), '2')
        if has_deprecated_steady:
            self.modelTimeOptions.addItem(
                self.tr(
                    "Deprecated: steady (constant relaxation coefficient)"),
                '-1')

        self.modelNTERUP = ComboModel(self.comboBoxNTERUP, 3, 1)
        self.modelNTERUP.addItem(self.tr("SIMPLE"), 'simple')
        self.modelNTERUP.addItem(self.tr("SIMPLEC"), 'simplec')
        self.modelNTERUP.addItem(self.tr("Inner iterations"), 'piso')
        self.comboBoxNTERUP.setSizeAdjustPolicy(QComboBox.AdjustToContents)

        self.modelTimeStop = ComboModel(self.comboBoxStopCrit, 2, 1)
        self.modelTimeStop.addItem(self.tr("Number of time steps"),
                                   "iterations")
        self.modelTimeStop.addItem(self.tr("Physical time (s)"),
                                   "maximum_time")
        self.modelTimeStop.addItem(self.tr("Additional time steps"),
                                   "iterations_add")
        self.modelTimeStop.addItem(self.tr("Additional physical time (s)"),
                                   "maximum_time_add")

        # Connections
        self.comboBoxOptions.activated[str].connect(self.slotTimePassing)
        self.lineEditDTREF.textChanged[str].connect(self.slotTimeStep)
        self.lineEditRELXST.textChanged[str].connect(self.slotRelaxCoef)
        self.lineEditCOUMAX.textChanged[str].connect(self.slotTimeOptionCOUMAX)
        self.lineEditFOUMAX.textChanged[str].connect(self.slotTimeOptionFOUMAX)
        self.lineEditCDTMIN.textChanged[str].connect(self.slotTimeOptionCDTMIN)
        self.lineEditCDTMAX.textChanged[str].connect(self.slotTimeOptionCDTMAX)
        self.lineEditVARRDT.textChanged[str].connect(self.slotTimeOptionVARRDT)
        self.checkBoxIPTLRO.clicked.connect(self.slotThermalTimeStep)
        self.comboBoxNTERUP.activated[str].connect(self.slotNTERUP)
        self.spinBoxNTERUP.valueChanged[int].connect(self.slotNTERUP2)
        self.comboBoxStopCrit.activated[str].connect(self.slotStopCritModel)
        self.lineEditStop.textChanged[str].connect(self.slotStopCritValue)

        # Validators

        validatorDTREF = DoubleValidator(self.lineEditDTREF, min=0.0)
        validatorDTREF.setExclusiveMin(True)
        validatorRELXST = DoubleValidator(self.lineEditRELXST,
                                          min=0.0,
                                          max=1.0)
        validatorRELXST.setExclusiveMin(True)
        validatorCOUMAX = DoubleValidator(self.lineEditCOUMAX, min=0.0)
        validatorCOUMAX.setExclusiveMin(True)
        validatorFOUMAX = DoubleValidator(self.lineEditFOUMAX, min=0.0)
        validatorFOUMAX.setExclusiveMin(True)
        validatorCDTMIN = DoubleValidator(self.lineEditCDTMIN,
                                          min=0.0,
                                          max=1.0)
        validatorCDTMIN.setExclusiveMin(True)
        validatorCDTMAX = DoubleValidator(self.lineEditCDTMAX, min=1.0)
        validatorVARRDT = DoubleValidator(self.lineEditVARRDT, min=0.0)
        validatorVARRDT.setExclusiveMin(True)

        self.lineEditDTREF.setValidator(validatorDTREF)
        self.lineEditRELXST.setValidator(validatorRELXST)
        self.lineEditCOUMAX.setValidator(validatorCOUMAX)
        self.lineEditFOUMAX.setValidator(validatorFOUMAX)
        self.lineEditCDTMIN.setValidator(validatorCDTMIN)
        self.lineEditCDTMAX.setValidator(validatorCDTMAX)
        self.lineEditVARRDT.setValidator(validatorVARRDT)

        self.validatorNTABS = IntValidator(self.lineEditStop, min=0)
        self.validatorTABS = DoubleValidator(self.lineEditStop, min=0.0)

        # Initialization

        idtvar = self.mdl.getTimePassing()
        idtvar_p = idtvar

        # Constraints on time step from Turbulence model

        from code_saturne.model.TurbulenceModel import TurbulenceModel
        model = TurbulenceModel(self.case).getTurbulenceModel()
        del TurbulenceModel

        if model in ('LES_Smagorinsky', 'LES_dynamique', 'LES_WALE'):
            idtvar = 0

            # Deactivate all modes except constant time step
            for itm in self.modelTimeOptions.getItems():
                if str(itm) != "0":
                    self.modelTimeOptions.disableItem(str_model=itm)

        # Constraints on time step from Lagrangian model

        from code_saturne.model.LagrangianModel import LagrangianModel
        model = LagrangianModel(self.case).getLagrangianModel()
        if model in ['one_way', 'two_way']:
            if idtvar not in [0, 1]:
                idtvar = 0

            # Deactivate certain modes
            for itm in self.modelTimeOptions.getItems():
                if str(itm) == "2":
                    self.modelTimeOptions.disableItem(str_model=itm)
                elif str(itm) == "1" and model == 'two_way':
                    self.modelTimeOptions.disableItem(str_model=itm)

        # Constraints on time step from compressible model

        from code_saturne.model.CompressibleModel import CompressibleModel
        model = CompressibleModel(self.case).getCompressibleModel()
        if model != 'off':
            if idtvar not in [0, 1]:
                idtvar = 0

            # Deactivate steady time step
            # Using list to allow additions in the future
            for itm in self.modelTimeOptions.getItems():
                if str(itm) in ["2"]:
                    self.modelTimeOptions.disableItem(str_model=itm)

            self.labelNTERUP.setText(
                "Velocity-Pressure algorithm\nsub-iterations on Navier-Stokes")
            self.comboBoxNTERUP.hide()
            self.spinBoxNTERUP.show()

        # Constraints on time step from groundwater model

        from code_saturne.model.GroundwaterModel import GroundwaterModel
        model = GroundwaterModel(self.case).getGroundwaterModel()
        if model != 'off':
            if idtvar not in [0, 1]:
                idtvar = 0

            # Deactivate all modes except constant time step
            for itm in self.modelTimeOptions.getItems():
                if str(itm) != "0":
                    self.modelTimeOptions.disableItem(str_model=itm)

        # Change time step option if required by model constraints

        if idtvar_p != idtvar:
            self.mdl.setTimePassing(idtvar)

        if self.mdl.thermalCase():
            if self.mdl.getThermalTimeStep() == 'on':
                self.checkBoxIPTLRO.setChecked(True)
            else:
                self.checkBoxIPTLRO.setChecked(False)
        else:
            self.labelIPTLRO.hide()
            self.checkBoxIPTLRO.hide()
            self.mdl.RemoveThermalTimeStepNode()

        self.__setTimePassingDisplay(idtvar)
        self.__setStopCritDisplay()

        self.case.undoStartGlobal()
    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)
        self.thermodata = ThermochemistryData(self.case)

        # Model for table View
        self.modelSpecies = StandardItemModelSpecies(self, self.thermodata)
        self.tableViewSpecies.setModel(self.modelSpecies)

        # Delegates
        delegateLabel = NameDelegate(self.tableViewSpecies)
        delegateChemicalFormula = ChemicalFormulaDelegate(
            self.tableViewSpecies)
        delegateCompFuel = ValueDelegate(self.tableViewSpecies)
        delegateCompOxi = ValueDelegate(self.tableViewSpecies)
        delegateCompProd = ValueDelegate(self.tableViewSpecies)
        delegateCoeffAbsorp = ValueDelegate(self.tableViewSpecies)

        self.tableViewSpecies.setItemDelegateForColumn(0, delegateLabel)
        self.tableViewSpecies.setItemDelegateForColumn(
            1, delegateChemicalFormula)
        self.tableViewSpecies.setItemDelegateForColumn(2, delegateCompFuel)
        self.tableViewSpecies.setItemDelegateForColumn(3, delegateCompOxi)
        self.tableViewSpecies.setItemDelegateForColumn(4, delegateCompProd)
        self.tableViewSpecies.setItemDelegateForColumn(5, delegateCoeffAbsorp)

        # tableView
        if QT_API == "PYQT4":
            self.tableViewSpecies.horizontalHeader().setResizeMode(
                QHeaderView.Stretch)
            self.tableViewSpecies.horizontalHeader().setResizeMode(
                0, QHeaderView.ResizeToContents)
            self.tableViewSpecies.horizontalHeader().setResizeMode(
                1, QHeaderView.ResizeToContents)
        elif QT_API == "PYQT5":
            self.tableViewSpecies.horizontalHeader().setSectionResizeMode(
                QHeaderView.Stretch)
            self.tableViewSpecies.horizontalHeader().setSectionResizeMode(
                0, QHeaderView.ResizeToContents)
            self.tableViewSpecies.horizontalHeader().setSectionResizeMode(
                1, QHeaderView.ResizeToContents)

        # Set models and number of elements for combo boxes
        self.modelGasCombustionOption = ComboModel(
            self.comboBoxGasCombustionOption, 1, 1)

        # Combo models to choose the mode to create the Janaf File

        self.userModeForChemicalReaction = ComboModel(self.comboBoxUserChoice,
                                                      2, 1)

        self.userModeForChemicalReaction.addItem("Automatic definition",
                                                 'auto')
        self.userModeForChemicalReaction.addItem("Defined by user", 'user')

        # Connections
        self.comboBoxUserChoice.activated[str].connect(self.slotUserChoice)
        self.comboBoxGasCombustionOption.activated[str].connect(
            self.slotGasCombustionOption)
        self.pushButtonThermochemistryData.pressed.connect(
            self.__slotSearchThermochemistryData)
        self.radioButtonCreateJanafFile.clicked.connect(
            self.slotCreateJanafFile)
        self.lineEditNbPointsTabu.textChanged[str].connect(
            self.slotNbPointsTabu)
        self.lineEditMaximumTemp.textChanged[str].connect(self.slotMaximumTemp)
        self.lineEditMinimumTemp.textChanged[str].connect(self.slotMinimumTemp)
        self.pushButtonAddSpecies.clicked.connect(self.slotAddSpecies)
        self.pushButtonDeleteSpecies.clicked.connect(self.slotDeleteSpecies)
        self.pushButtonGenerateJanafFile.clicked.connect(
            self.slotGenerateJanafFile)
        self.lineEditFuel.textChanged[str].connect(self.slotFuel)
        self.lineEditO2.textChanged[str].connect(self.slotVolPropO2)
        self.lineEditN2.textChanged[str].connect(self.slotVolPropN2)
        self.lineEditCOyield.textChanged[str].connect(self.slotCOyield)
        self.lineEditCSyield.textChanged[str].connect(self.slotCSyield)
        self.modelSpecies.dataChanged.connect(self.dataChanged)

        # Validators
        validatorNbPointsTabu = IntValidator(self.lineEditNbPointsTabu, min=1)
        validatorMaximumTemp = DoubleValidator(self.lineEditMaximumTemp,
                                               min=273.0)
        validatorMinimumTemp = DoubleValidator(self.lineEditMinimumTemp,
                                               min=273.0)
        rx = "[chonlCHONL()][CHONLchonl()0-9]{0," + str(LABEL_LENGTH_MAX -
                                                        1) + "}"
        validatorFuel = RegExpValidator(self.lineEditFuel, QRegExp(rx))
        validatorO2 = DoubleValidator(self.lineEditO2, min=1e-12, max=1.0)
        validatorN2 = DoubleValidator(self.lineEditN2, min=0.0, max=1.0)
        validatorCOyield = DoubleValidator(self.lineEditCOyield, min=0.0)
        validatorCSyield = DoubleValidator(self.lineEditCSyield, min=0.0)

        self.lineEditNbPointsTabu.setValidator(validatorNbPointsTabu)
        self.lineEditMaximumTemp.setValidator(validatorMaximumTemp)
        self.lineEditMinimumTemp.setValidator(validatorMinimumTemp)
        self.lineEditFuel.setValidator(validatorFuel)
        self.lineEditO2.setValidator(validatorO2)
        self.lineEditN2.setValidator(validatorN2)
        self.lineEditCOyield.setValidator(validatorCOyield)
        self.lineEditCSyield.setValidator(validatorCSyield)

        NbPointsTabu = self.thermodata.getNbPointsTabu()
        MaximumTemp = self.thermodata.getMaximumTemp()
        MinimumTemp = self.thermodata.getMinimumTemp()
        Option_UserMode = self.thermodata.getUserModeForChemicalReaction()
        ChemicalFormulaFuel = self.thermodata.getChemicalFormulaFuel()
        VolPropO2 = self.thermodata.getVolPropO2()
        VolPropN2 = self.thermodata.getVolPropN2()
        COyield = self.thermodata.getCOyield()
        CSyield = self.thermodata.getCSyield()

        self.lineEditNbPointsTabu.setText(str(NbPointsTabu))
        self.lineEditMaximumTemp.setText(str(MaximumTemp))
        self.lineEditMinimumTemp.setText(str(MinimumTemp))
        self.lineEditFuel.setText(str(ChemicalFormulaFuel))
        self.lineEditO2.setText(str(VolPropO2))
        self.lineEditN2.setText(str(VolPropN2))
        self.lineEditCOyield.setText(str(COyield))
        self.lineEditCSyield.setText(str(CSyield))

        # Initialize Widgets

        self.tableViewSpecies.reset()
        self.modelSpecies = StandardItemModelSpecies(self, self.thermodata)
        self.tableViewSpecies.setModel(self.modelSpecies)

        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 and name != "":
            self.labelThermochemistryFile.setText(str(name))
            self.pushButtonThermochemistryData.setStyleSheet(
                "background-color: green")
        else:
            self.pushButtonThermochemistryData.setStyleSheet(
                "background-color: red")

        self.radioButtonCreateJanafFile.hide()

        if self.thermodata.getCreateThermoDataFile() == 'on':
            self.radioButtonCreateJanafFile.setChecked(True)
            self.userModeForChemicalReaction.setItem(str_model=Option_UserMode)
            for label in self.thermodata.getSpeciesNamesList():
                self.modelSpecies.newItem(label)
        else:
            self.radioButtonCreateJanafFile.setChecked(False)

        # for the moment the option to create Janaf file in the GUI is only available with d3p
        if model == 'd3p':
            self.radioButtonCreateJanafFile.show()
            self.groupBoxTabulation.show()
            self.groupBoxChemicalReaction.show()
            self.groupBoxDefinedByUser.show()
            self.groupBoxGenerateDataFile.show()
            self.groupBoxAutomatic.show()

        self.slotCreateJanafFile()

        self.case.undoStartGlobal()
class StartRestartAdvancedDialogView(QDialog,
                                     Ui_StartRestartAdvancedDialogForm):
    """
    Building of popup window for advanced options.
    """
    def __init__(self, parent, case, default):
        """
        Constructor
        """
        QDialog.__init__(self, parent)

        Ui_StartRestartAdvancedDialogForm.__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 and items
        self.modelFreq = ComboModel(self.comboBoxFreq, 4, 1)

        self.modelFreq.addItem(self.tr("Never"), 'Never')
        self.modelFreq.addItem(self.tr("Only at the end of the calculation"),
                               'At the end')
        self.modelFreq.addItem(self.tr("4 restart checkpoints"), '4 output')
        self.modelFreq.addItem(self.tr("Checkpoints frequency :"), 'Frequency')

        # Connections

        self.comboBoxFreq.activated[str].connect(self.slotFreq)
        self.lineEditNSUIT.textChanged[str].connect(self.slotNsuit)

        # Validator

        validatorNSUIT = IntValidator(self.lineEditNSUIT, min=0)
        self.lineEditNSUIT.setValidator(validatorNSUIT)

        # Read of auxiliary file if calculation restart is asked

        if self.default['restart']:
            self.groupBoxRestart.show()

            if self.default['restart_with_auxiliary'] == 'on':
                self.checkBoxReadAuxFile.setChecked(True)
            else:
                self.checkBoxReadAuxFile.setChecked(False)
        else:
            self.groupBoxRestart.hide()

        # Frequency of rescue of restart file

        if self.default['restart_rescue'] == -2:
            self.nsuit = -2
            self.lineEditNSUIT.setDisabled(True)
            self.freq = 'Never'
        elif self.default['restart_rescue'] == -1:
            self.nsuit = -1
            self.lineEditNSUIT.setDisabled(True)
            self.freq = 'At the end'
        elif self.default['restart_rescue'] == 0:
            self.nsuit = 0
            self.lineEditNSUIT.setDisabled(True)
            self.freq = '4 output'
        else:
            self.nsuit = self.default['restart_rescue']
            self.lineEditNSUIT.setEnabled(True)
            self.freq = 'Frequency'
        self.modelFreq.setItem(str_model=self.freq)
        self.lineEditNSUIT.setText(str(self.nsuit))

        self.case.undoStartGlobal()
示例#11
0
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_LagrangianStatisticsForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.model = LagrangianStatisticsModel(self.case)

        self.checkBoxISUIST.clicked.connect(self.slotISUIST)
        self.lineEditNBCLST.textChanged[str].connect(self.slotNBCLST)

        self.groupBoxISTALA.clicked.connect(self.slotISTALA)
        self.lineEditIDSTNT.editingFinished.connect(self.slotIDSTNT)
        self.lineEditNSTIST.editingFinished.connect(self.slotNSTIST)

        self.lineEditSEUIL.textChanged[str].connect(self.slotSEUIL)

        self.groupBoxIENSI3.clicked.connect(self.slotIENSI3)

        validatorNBCLST = IntValidator(self.lineEditNBCLST, min=0) # max=100

        validatorIDSTNT = IntValidator(self.lineEditIDSTNT, min=0)
        validatorIDSTNT.setExclusiveMin(True)
        validatorNSTIST = IntValidator(self.lineEditNSTIST, min=0)
        validatorSEUIL = DoubleValidator(self.lineEditSEUIL, min=0.)

        self.lineEditNBCLST.setValidator(validatorNBCLST)
        self.lineEditIDSTNT.setValidator(validatorIDSTNT)
        self.lineEditNSTIST.setValidator(validatorNSTIST)
        self.lineEditSEUIL.setValidator(validatorSEUIL)

        # initialize Widgets
        status = self.model.getRestartStatisticsStatus()
        if status == "on":
            self.checkBoxISUIST.setChecked(True)
        else:
            self.checkBoxISUIST.setChecked(False)

        nclust = self.model.getGroupOfParticlesValue()
        self.lineEditNBCLST.setText(str(nclust))

        it = self.model.getIterationStart()
        self.lineEditIDSTNT.setText(str(it))

        it = self.model.getIterSteadyStart()
        self.lineEditNSTIST.setText(str(it))

        seuil = self.model.getThresholdValue()
        self.lineEditSEUIL.setText(str(seuil))

        # volume
        status = self.model.getVolumeStatisticsStatus()
        if status == "on":
            self.groupBoxISTALA.setChecked(True)
        else:
            self.groupBoxISTALA.setChecked(False)
        self.slotISTALA()

        # boundary
        status = self.model.getBoundaryStatisticsStatus()
        if status == "on":
            self.groupBoxIENSI3.setChecked(True)
        else:
            self.groupBoxIENSI3.setChecked(False)
        self.slotIENSI3()

        self.case.undoStartGlobal()
示例#12
0
class SolutionDomainView(QWidget, Ui_SolutionDomainForm):
    """
    """
    def __init__(self, parent, case, stbar, tree):
        """
        Constructor
        """
        QWidget.__init__(self, parent)
        Ui_SolutionDomainForm.__init__(self)
        self.setupUi(self)

        self.root = parent
        self.stbar = stbar
        self.case = case
        self.browser = tree

        self.case.undoStopGlobal()
        self.mdl = SolutionDomainModel(self.case)

        # 0) Mesh Input

        self.mesh_origin = self.mdl.getMeshOrigin()

        self.mesh_input = self.mdl.getMeshInput()

        if self.mesh_origin == "mesh_import":
            self.radioButtonImport.setChecked(True)
            self.radioButtonExists.setChecked(False)
            self.radioButtonCartesianMesh.setChecked(False)

            self.frameMeshInput.hide()
            self.frameMeshCartesian.hide()
            self.frameMeshImport.show()

        elif self.mesh_origin == "mesh_input":
            self.radioButtonImport.setChecked(False)
            self.radioButtonExists.setChecked(True)
            self.radioButtonCartesianMesh.setChecked(False)

            self.frameMeshImport.hide()
            self.frameMeshCartesian.hide()
            self.frameMeshInput.show()
            self.lineEditMeshInput.setText(self.mesh_input)

        elif self.mesh_origin == "mesh_cartesian":
            self.radioButtonImport.setChecked(False)
            self.radioButtonExists.setChecked(False)
            self.radioButtonCartesianMesh.setChecked(True)

            self.frameMeshInput.hide()
            self.frameMeshImport.hide()
            self.frameMeshCartesian.show()

        self.radioButtonImport.clicked.connect(self.slotSetImportMesh)
        self.radioButtonExists.clicked.connect(self.slotSetInputMesh)
        self.radioButtonCartesianMesh.clicked.connect(
            self.slotSetCartesianMesh)
        self.toolButtonMeshInput.pressed.connect(self.selectInputMesh)
        self.lineEditMeshInput.textChanged[str].connect(self.modifyInputMesh)

        self.cartParams = {
            "x_ncells": self.lineEditXNcells,
            "y_ncells": self.lineEditYNcells,
            "z_ncells": self.lineEditZNcells,
            "x_min": self.lineEditXmin,
            "x_max": self.lineEditXmax,
            "y_min": self.lineEditYmin,
            "y_max": self.lineEditYmax,
            "z_min": self.lineEditZmin,
            "z_max": self.lineEditZmax,
            "x_prog": self.lineEditXprog,
            "y_prog": self.lineEditYprog,
            "z_prog": self.lineEditZprog
        }

        # We use lambda to connect all 9 lineEdits to the same function.
        # val corresponds to the string, and "key=k" is necessary for the connect
        # method to evaluate 'k' during creation. Otherwise last value of 'k' is
        # used for all.
        for k in self.cartParams.keys():
            self.cartParams[k].textChanged[str].connect(
                lambda val, key=k: self.slotSetCartesianParam(val, key))
            # set validator
            if k.split("_")[1] == "ncells":
                _v = IntValidator(self.cartParams[k], min=1)
                self.cartParams[k].setValidator(_v)
            else:
                _v = DoubleValidator(self.cartParams[k])
                self.cartParams[k].setValidator(_v)

        self.cartParams["x_law"] = ComboModel(self.comboBoxXlaw, 3, 1)
        self.cartParams["y_law"] = ComboModel(self.comboBoxYlaw, 3, 1)
        self.cartParams["z_law"] = ComboModel(self.comboBoxZlaw, 3, 1)
        for k in ("x_law", "y_law", "z_law"):
            self.cartParams[k].addItem(self.tr("constant"), "constant")
            self.cartParams[k].addItem(self.tr("geometric"), "geometric")
            self.cartParams[k].addItem(self.tr("parabolic"), "parabolic")

        self.comboBoxXlaw.activated[str].connect(
            lambda val: self.slotSetCartesianParam(val, "x_law"))
        self.comboBoxYlaw.activated[str].connect(
            lambda val: self.slotSetCartesianParam(val, "y_law"))
        self.comboBoxZlaw.activated[str].connect(
            lambda val: self.slotSetCartesianParam(val, "z_law"))

        # Set initial values
        for k in self.cartParams.keys():
            d = k.split("_")[0] + "_direction"
            p = k.split("_")[1]
            val = self.mdl.getCartesianParam(d, p)
            self.slotSetCartesianParam(val, k)

        # 1) Meshes directory

        self.mesh_dirs = [None]

        d = self.mdl.getMeshDir()
        study_path = os.path.split(self.case['case_path'])[0]

        if d is None:
            d = os.path.join(study_path, 'MESH')
        elif not os.path.abspath(d):
            d = os.path.join(self.case['case_path'], d)

        if d != None:
            if os.path.isdir(d):
                self.lineEditMeshDir.setText(
                    RelOrAbsPath(d, self.case['case_path']))
                self.mesh_dirs[0] = d

        self.case['mesh_path'] = self.mesh_dirs[0]

        package = self.case['package']

        # User and global mesh directories

        for config_file in [
                package.get_user_configfile(),
                package.get_global_configfile()
        ]:
            cfg = configparser.ConfigParser()
            cfg.read(config_file)
            if cfg.has_option('run', 'meshpath'):
                cfg_mesh_dirs = cfg.get('run', 'meshpath').split(':')
                for d in cfg_mesh_dirs:
                    self.mesh_dirs.append(d)

        del (package)

        # 2) Meshes selection layout

        # 2.1) Model for meshes table
        self.modelMeshes = StandardItemModelMeshes(self.mdl)
        self.tableViewMeshes.setModel(self.modelMeshes)
        self.tableViewMeshes.resizeColumnsToContents()
        self.tableViewMeshes.resizeRowsToContents()

        delegateName = MeshNameDelegate(self.tableViewMeshes)
        self.tableViewMeshes.setItemDelegateForColumn(0, delegateName)

        delegateFormat = MeshFormatDelegate(self.tableViewMeshes,
                                            self._tableViewLayout)
        self.tableViewMeshes.setItemDelegateForColumn(1, delegateFormat)

        delegateNumber = MeshNumberDelegate(self.tableViewMeshes)
        self.tableViewMeshes.setItemDelegateForColumn(2, delegateNumber)

        delegateGroupFaces = GroupDelegate(self.tableViewMeshes)
        self.tableViewMeshes.setItemDelegateForColumn(4, delegateGroupFaces)

        delegateGroupCells = GroupDelegate(self.tableViewMeshes)
        self.tableViewMeshes.setItemDelegateForColumn(5, delegateGroupCells)

        self.groupBoxMeshes.resizeEvent = self.MeshesResizeEvent

        # 2.2) Connections

        self.pushButtonAddMesh.clicked.connect(self.slotSearchMesh)
        self.pushButtonDeleteMesh.clicked.connect(self.slotDeleteMesh)

        # 3) Initialize meshes list

        # 3.1) Meshes default directory

        self.toolButtonMeshDir.pressed.connect(self.searchDir)
        self.toolButtonMeshDirClear.pressed.connect(self.clearDir)

        # 3.2) Meshes list

        msg = ""
        nameList = self.mdl.getMeshList()
        log.debug("__init__ -> nameList = %s " % nameList)

        if nameList:
            for i in range(len(nameList)):
                mesh = nameList[i]
                if mesh[1] != None:
                    path = os.path.join(mesh[1], mesh[0])
                else:
                    path = mesh[0]
                if not os.path.isabs(path) and self.case['mesh_path'] != None:
                    path = os.path.join(self.case['mesh_path'], path)
                if not (os.path.isfile(path) and os.path.isabs(path)):
                    msg = msg + path + '\n'

        if msg != "":
            msg = msg + '\n'
            title = self.tr("WARNING")
            msg2 = self.tr(
                "The following mesh files are not present or\n" +
                "in the meshes directory search path:\n\n" + msg +
                "Verify existence and location of the mesh files,\n" +
                "and the 'Mesh Directory' section.")
            QMessageBox.warning(self, title, msg2)

        self._tableViewLayout()

        # Combomodels

        self.modelArg_cs_verif = ComboModel(self.comboBoxRunType, 4, 1)

        self.modelArg_cs_verif.addItem(self.tr("Import mesh only"), 'none')
        self.modelArg_cs_verif.addItem(self.tr("Mesh preprocessing only"),
                                       'mesh preprocess')
        self.modelArg_cs_verif.addItem(self.tr("Mesh quality criteria only"),
                                       'mesh quality')
        self.modelArg_cs_verif.addItem(self.tr("Standard Computation"),
                                       'standard')

        self.modelArg_cs_verif.setItem(str_model=self.case['run_type'])

        if self.mesh_input != None:
            self.modelArg_cs_verif.disableItem(str_model='none')
        else:
            self.modelArg_cs_verif.enableItem(str_model='none')

        self.comboBoxRunType.activated[str].connect(self.slotArgRunType)

        # Checkboxes

        self.checkBoxMeshRestart.setChecked(
            not self.mdl.getPreprocessOnRestart())
        self.checkBoxMeshRestart.clicked.connect(self.slotMeshRestart)

        self.checkBoxMeshSave.setChecked(self.mdl.getMeshSaveOnModify())
        self.checkBoxMeshSave.clicked.connect(self.slotMeshSaveOnModify)

        # Undo/redo

        self.case.undoStartGlobal()

        # Update tree

        self.browser.configureTree(self.case)
示例#13
0
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;
if (xray2 < xr2) mesh_viscosity = 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[X] = 1;
mesh_viscosity[Y] = 1;
mesh_viscosity[Z] = 1;
if (xray2 < xr2) {
    mesh_viscosity[X] = 1e10;
    mesh_viscosity[Y] = 1e10;
    mesh_viscosity[Z] = 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
        self.notebook = NotebookModel(self.case)

        # 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.lineEditNALINF.textChanged[str].connect(self.slotNalinf)
        self.comboBoxVISCOSITY.activated[str].connect(self.slotViscosityType)
        self.pushButtonFormula.clicked.connect(self.slotFormula)

        # Validators
        validatorNALINF = IntValidator(self.lineEditNALINF, min=0)
        self.lineEditNALINF.setValidator(validatorNALINF)

        # Settings
        nalinf = self.mdl.getSubIterations()
        self.lineEditNALINF.setText(str(nalinf))
        value = self.mdl.getViscosity()
        self.modelVISCOSITY.setItem(str_model=value)
        exp = self.mdl.getFormula()
        if exp:
            self.pushButtonFormula.setStyleSheet("background-color: green")
            self.pushButtonFormula.setToolTip(exp)
        else:
            self.pushButtonFormula.setStyleSheet("background-color: red")

        self.case.undoStartGlobal()
示例#14
0
 def createEditor(self, parent, option, index):
     editor = QLineEdit(parent)
     validator = IntValidator(editor, min=0)
     editor.setValidator(validator)
     editor.installEventFilter(self)
     return editor
示例#15
0
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)

        # Default settings
        self.default = {}
        self.default['scheme_order'] = self.model.getSchemeOrder()
        self.default['regular_particles'] = self.model.getRegularParticles()
        self.result = self.default.copy()

        # Combo model
        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')
        if CoalCombustionModel(
                self.case).getCoalCombustionModel("only") != 'off':
            self.modelIPHYLA.addItem(self.tr("Pulverised coal model"), 'coal')

        # Combo SDEs scheme
        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")

        # Connections
        self.checkBoxISUILA.clicked.connect(self.slotISUILA)
        self.checkBoxISTTIO.clicked.connect(self.slotISTTIO)
        self.checkBoxIDEPST.clicked.connect(self.slotIDEPST)
        self.comboBoxIPHYLA.activated[str].connect(self.slotIPHYLA)
        self.comboBoxNORDRE.activated[str].connect(self.slotNORDRE)
        self.checkBoxITPVAR.clicked.connect(self.slotITPVAR)
        self.checkBoxIMPVAR.clicked.connect(self.slotIMPVAR)
        self.checkBoxIENCRA.clicked.connect(self.slotIENCRA)
        #
        self.lineEditNSTITS.textChanged[str].connect(self.slotNSTITS)
        self.checkBoxLTSDYN.clicked.connect(self.slotLTSDYN)
        self.checkBoxLTSMAS.clicked.connect(self.slotLTSMAS)
        self.checkBoxLTSTHE.clicked.connect(self.slotLTSTHE)
        #
        self.checkBoxMODCPL.clicked.connect(self.slotMODCPL)

        # Validators
        validatorNSTITS = IntValidator(self.lineEditNSTITS)

        self.lineEditNSTITS.setValidator(validatorNSTITS)

        # initialize Widgets
        model = self.model.getLagrangianModel()

        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.getDepositionSubmodel()
        if status == "on":
            self.checkBoxIDEPST.setChecked(True)
        else:
            self.checkBoxIDEPST.setChecked(False)

        order = str(self.result['scheme_order'])
        self.modelNORDRE.setItem(str_model=order)

        if (model == "frozen"):
            self.labelISTTIO.setDisabled(True)
            self.checkBoxISTTIO.setChecked(True)
            self.checkBoxISTTIO.setDisabled(True)

        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)

        part_model = self.model.getParticlesModel()
        self.modelIPHYLA.setItem(str_model=part_model)
        self.slotIPHYLA(self.modelIPHYLA.dicoM2V[part_model])

        regular_particles = self.model.getRegularParticles()
        if regular_particles >= 1:
            self.checkBoxMODCPL.setChecked(False)
        else:
            self.checkBoxMODCPL.setChecked(True)

        self.case.undoStartGlobal()
 def createEditor(self, parent, option, index):
     editor = QLineEdit(parent)
     validator = IntValidator(editor, min=1)
     editor.setValidator(validator)
     return editor
示例#17
0
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_GlobalNumericalParameters.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = GlobalNumericalParametersModel(self.case)

        # Combo model
        self.modelVelocityAlgorithm = ComboModel(
            self.comboBoxVelocityAlgorithm, 3, 1)
        self.modelVelocityAlgorithm.addItem(self.tr("Standard"),
                                            "standard_difvit")
        self.modelVelocityAlgorithm.addItem(self.tr("Coupled"),
                                            "coupled_difvitc")
        self.modelVelocityAlgorithm.addItem(
            self.tr("Mean velocity - relative velocity"),
            "mean_velocity_relative_velocity")

        mfm = MainFieldsModel(self.case)
        if len(mfm.getFieldIdList()) < 2:
            self.modelVelocityAlgorithm.disableItem(2)
        else:
            self.modelVelocityAlgorithm.enableItem(2)

        # Validator
        validatorMaxRestart = IntValidator(self.lineEditMaxRestart, min=0)
        validatorSplitting = DoubleValidator(self.lineEditTimeSplitting,
                                             min=0.)
        validatorPRelax = DoubleValidator(self.lineEditPressureRelaxation,
                                          min=0.)
        validatorMinP = DoubleValidator(self.lineEditMinimumPressure)
        validatorMaxP = DoubleValidator(self.lineEditMaximumPressure)

        validatorMaxRestart.setExclusiveMin(False)
        validatorSplitting.setExclusiveMin(True)
        validatorPRelax.setExclusiveMin(True)

        self.lineEditMaxRestart.setValidator(validatorMaxRestart)
        self.lineEditTimeSplitting.setValidator(validatorSplitting)
        self.lineEditPressureRelaxation.setValidator(validatorPRelax)
        self.lineEditMinimumPressure.setValidator(validatorMinP)
        self.lineEditMaximumPressure.setValidator(validatorMaxP)

        # Connections
        self.checkBoxRestart.clicked.connect(self.slotRestart)
        self.checkBoxPotentialState.clicked.connect(self.slotPotentialState)
        self.checkBoxFacesReconstruction.clicked.connect(
            self.slotFacesReconstruction)
        self.checkBoxMultigrid.clicked.connect(self.slotMultigrid)
        self.lineEditMinimumPressure.textChanged[str].connect(
            self.slotMinimumPressure)
        self.lineEditMaximumPressure.textChanged[str].connect(
            self.slotMaximumPressure)
        self.pushButtonAdvanced.clicked.connect(self.slotAdvancedOptions)
        self.lineEditMaxRestart.textChanged[str].connect(self.slotMaxRestart)
        self.lineEditTimeSplitting.textChanged[str].connect(
            self.slotTimeSplitting)
        self.lineEditPressureRelaxation.textChanged[str].connect(
            self.slotPressureRelaxation)
        self.checkBoxUpwindAlphaEnergy.clicked.connect(
            self.slotUpwindAlphaEnergy)
        self.checkBoxStopRestart.clicked.connect(self.slotStopRestart)
        self.comboBoxVelocityAlgorithm.activated[str].connect(
            self.slotVelocityAlgorithm)

        self.checkBoxRegulBadCells.clicked.connect(self.slotRegulateBadCells)

        # Initialize widget
        status = self.mdl.getRestartTimeStep()
        if status == 'on':
            self.checkBoxRestart.setChecked(1)
            self.groupBoxRestartOption.show()

            value = self.mdl.getMaxNumberOfRestart()
            self.lineEditMaxRestart.setText(str(value))
            value = self.mdl.getTimeSplit()
            self.lineEditTimeSplitting.setText(str(value))
            value = self.mdl.getPressureRelaxation()
            self.lineEditPressureRelaxation.setText(str(value))
            status = self.mdl.getUpwindScheme()
            if status == 'on':
                self.checkBoxUpwindAlphaEnergy.setChecked(True)
            else:
                self.checkBoxUpwindAlphaEnergy.setChecked(False)
            status = self.mdl.getStopNoConvergence()
            if status == 'on':
                self.checkBoxStopRestart.setChecked(True)
            else:
                self.checkBoxStopRestart.setChecked(False)
        else:
            self.checkBoxRestart.setChecked(0)
            self.groupBoxRestartOption.hide()

        is_compressible = False
        for fid in mfm.getFieldIdList():
            if mfm.getCompressibleStatus(int(fid)) == 'on':
                is_compressible = True
                break

        if is_compressible:
            self.mdl.setPotentielState('off')
            self.checkBoxPotentialState.setChecked(0)
            self.checkBoxPotentialState.setEnabled(False)
        else:
            status = self.mdl.getPotentielState()
            if status == 'on':
                self.checkBoxPotentialState.setChecked(1)
            else:
                self.checkBoxPotentialState.setChecked(0)

        status = self.mdl.getFacesReconstruction()
        if status == 'on':
            self.checkBoxFacesReconstruction.setChecked(1)
        else:
            self.checkBoxFacesReconstruction.setChecked(0)

        status = self.mdl.getRegulateBadCElls()
        self.checkBoxRegulBadCells.setChecked(status == 'on')

        status = self.mdl.getMultigridStatus()
        if status == 'on':
            self.checkBoxMultigrid.setChecked(1)
        else:
            self.checkBoxMultigrid.setChecked(0)

        value = self.mdl.getMinPressure()
        self.lineEditMinimumPressure.setText(str(value))
        value = self.mdl.getMaxPressure()
        self.lineEditMaximumPressure.setText(str(value))

        model = self.mdl.getVelocityPredictorAlgo()
        self.modelVelocityAlgorithm.setItem(str_model=model)

        self.case.undoStartGlobal()

        predefined_flow = MainFieldsModel(self.case).getPredefinedFlow()
        if predefined_flow in ["free_surface", "droplet_flow", "multiregime"]:
            self.modelVelocityAlgorithm.setItem(str_model="coupled_difvitc")
            self.comboBoxVelocityAlgorithm.setEnabled(False)
        elif predefined_flow == "boiling_flow":
            self.modelVelocityAlgorithm.setItem(
                str_model="mean_velocity_relative_velocity")
            self.comboBoxVelocityAlgorithm.setEnabled(False)
 def createEditor(self, parent, option, index):
     editor = QLineEdit(parent)
     validator = IntValidator(editor, min=0)
     validator.setExclusiveMin(False)
     editor.setValidator(validator)
     return editor
示例#19
0
class GlobalNumericalParametersAdvancedOptionsDialogView(
        QDialog, Ui_GlobalNumericalParametersAdvancedOptionsDialog):
    """
    Advanced global numerical parameters layout.
    """
    def __init__(self, parent, case, default):
        """
        Constructor
        """
        QDialog.__init__(self, parent)

        Ui_GlobalNumericalParametersAdvancedOptionsDialog.__init__(self)
        self.setupUi(self)
        title = self.tr("Advanced options for Global Numerical Parameters")
        self.setWindowTitle(title)
        self.default = default
        self.result = self.default.copy()
        self.case = case

        self.case.undoStopGlobal()

        # Combo model
        self.modelVelocityUpdate = ComboModel(self.comboBoxVelocityUpdate, 4,
                                              1)
        self.modelVelocityUpdate.addItem(
            self.tr("By the pressure gradient increment"),
            "pressure_gradient_increment")
        self.modelVelocityUpdate.addItem(
            self.tr("RT0 by flow rate (internal+boundary)"), "flow_rate")
        self.modelVelocityUpdate.addItem(self.tr("RT0 by flumas(b) increment"),
                                         "flumas_increment")
        self.modelVelocityUpdate.addItem(
            self.tr("By means of Conv+Diff+ST equation"), "conv_diff_equation")

        self.modelGradientPressure = ComboModel(self.comboBoxGradientPressure,
                                                5, 1)
        self.modelGradientPressure.addItem(self.tr("Mass ponderation"),
                                           "mass_ponderation")
        self.modelGradientPressure.addItem(self.tr("Standard"), "standard")
        self.modelGradientPressure.addItem(
            self.tr("Controlled mass ponderation"), "controlled_mass_pound")
        self.modelGradientPressure.addItem(self.tr("Momentum ponderation"),
                                           "momentum_pound")
        self.modelGradientPressure.addItem(self.tr("Gravity+HL+ST momentum"),
                                           "gravity_momentum")

        # Validator
        validatorSumAlpha = DoubleValidator(self.lineEditMaxSumAlpha,
                                            min=0.,
                                            max=1.)
        validatorAlphaP = IntValidator(self.lineEditNumberAlphaPCycle, min=1)

        validatorSumAlpha.setExclusiveMin(False)
        validatorAlphaP.setExclusiveMin(False)

        self.lineEditMaxSumAlpha.setValidator(validatorSumAlpha)
        self.lineEditNumberAlphaPCycle.setValidator(validatorAlphaP)

        # Initialization
        if self.result['pressure_symetrisation'] == 'on':
            self.checkBoxSymetPressure.setChecked(True)
        else:
            self.checkBoxSymetPressure.setChecked(False)

        self.modelVelocityUpdate.setItem(
            str_model=self.result['velocity_update'])
        self.modelGradientPressure.setItem(
            str_model=self.result['pressure_gradient'])
        self.lineEditMaxSumAlpha.setText(str(self.result['max_sum_alpha']))
        self.lineEditNumberAlphaPCycle.setText(
            str(self.result['alpha_p_cycle']))

        self.case.undoStartGlobal()
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_TimeStep.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = TimeStepModel(self.case)

        # Combo box models

        self.modelTimeStepOption = ComboModel(self.comboBoxTimeStepOption, 3, 1)
        self.modelTimeStepOption.addItem(self.tr("Constant"), "constant")
        self.modelTimeStepOption.addItem(self.tr("Adaptive"), "uniform")
        self.modelTimeStepOption.addItem(self.tr("Steady"), "steady")

        self.modelTimeStop = ComboModel(self.comboBoxTimeStopType, 2, 1)
        self.modelTimeStop.addItem(self.tr("Number of time steps"), "iteration")
        self.modelTimeStop.addItem(self.tr("Time analysis (s)"), "time")

        # Validators

        validatorRefT   = DoubleValidator(self.lineEditReferenceTimeStep, min = 0.0)
        validatorNumT   = IntValidator(self.lineEditNumberTimeStep, min = 0)
        validatorAnaT   = DoubleValidator(self.lineEditTimeAnalysis)
        validatorDtMin  = DoubleValidator(self.lineEditDtMin, min = 0.0)
        validatorDtMax  = DoubleValidator(self.lineEditDtMax, min = 0.0)
        validatorIncMax = DoubleValidator(self.lineEditDtIncreasingMax, min = 0.0)
        validatorDecMax = DoubleValidator(self.lineEditDtDecreasingMax, min = 0.0)

        validatorRefT.setExclusiveMin(True)
        validatorNumT.setExclusiveMin(True)
        validatorDtMin.setExclusiveMin(True)
        validatorDtMax.setExclusiveMin(True)
        validatorIncMax.setExclusiveMin(True)
        validatorDecMax.setExclusiveMin(True)

        self.lineEditReferenceTimeStep.setValidator(validatorRefT)
        self.lineEditNumberTimeStep.setValidator(validatorNumT)
        self.lineEditTimeAnalysis.setValidator(validatorAnaT)
        self.lineEditDtMin.setValidator(validatorDtMin)
        self.lineEditDtMax.setValidator(validatorDtMax)
        self.lineEditDtIncreasingMax.setValidator(validatorIncMax)
        self.lineEditDtDecreasingMax.setValidator(validatorDecMax)

        # tableViewCourantFourier

        self.tableModelCourantFourier = StandardItemModelCourantFourier(self.mdl)
        self.tableViewCourantFourier.setModel(self.tableModelCourantFourier)
        self.tableViewCourantFourier.resizeColumnsToContents()
        self.tableViewCourantFourier.resizeRowsToContents()
        if QT_API == "PYQT4":
            self.tableViewCourantFourier.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
            self.tableViewCourantFourier.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
            self.tableViewCourantFourier.horizontalHeader().setResizeMode(0,QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewCourantFourier.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
            self.tableViewCourantFourier.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
            self.tableViewCourantFourier.horizontalHeader().setSectionResizeMode(0,QHeaderView.Stretch)
        self.tableViewCourantFourier.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tableViewCourantFourier.setSelectionMode(QAbstractItemView.SingleSelection)

        delegateMaxFourier = ValueDelegate(self.tableViewCourantFourier)
        delegateMaxCourant = ValueDelegate(self.tableViewCourantFourier)

        self.tableViewCourantFourier.setItemDelegateForColumn(1, delegateMaxFourier)
        self.tableViewCourantFourier.setItemDelegateForColumn(2, delegateMaxCourant)

        # Connect signals to slots
        self.comboBoxTimeStepOption.activated[str].connect(self.slotTimeStepOption)
        self.comboBoxTimeStopType.activated[str].connect(self.slotTimeStop)
        self.lineEditReferenceTimeStep.textChanged[str].connect(self.slotReferenceTimeStep)
        self.lineEditNumberTimeStep.textChanged[str].connect(self.slotNumberTimeStep)
        self.lineEditTimeAnalysis.textChanged[str].connect(self.slotTimeAnalysis)
        self.lineEditDtMin.textChanged[str].connect(self.slotDtMin)
        self.lineEditDtMax.textChanged[str].connect(self.slotDtMax)
        self.lineEditDtIncreasingMax.textChanged[str].connect(self.slotDtIncreasingMax)
        self.lineEditDtDecreasingMax.textChanged[str].connect(self.slotDtDecreasingMax)
        self.tableModelCourantFourier.dataChanged.connect(self.dataChanged)

        # Initialize widget
        self.initializeVariables()

        self.case.undoStartGlobal()
示例#21
0
class ProfilesView(QWidget, Ui_ProfilesForm):
    """
    """
    def __init__(self, parent, case, stbar):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_ProfilesForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = ProfilesModel(self.case)
        self.notebook = NotebookModel(self.case)

        #  Initialize variables concerning the display of the Hlist

        self.entriesNumber = 0

        # Models
        self.modelProfile = StandardItemModelProfile()
        self.treeViewProfile.setModel(self.modelProfile)
        self.treeViewProfile.resizeColumnToContents(0)

        # QListView layout
        self.gridlayout1 = QGridLayout(self.widgetDrag)
        self.gridlayout1.setContentsMargins(0, 0, 0, 0)
        self.DragList = QListView(self.widgetDrag)
        self.gridlayout1.addWidget(self.DragList, 0, 0, 1, 1)

        self.gridlayout2 = QGridLayout(self.widgetDrop)
        self.gridlayout2.setContentsMargins(0, 0, 0, 0)
        self.DropList = QListView(self.widgetDrop)
        self.gridlayout2.addWidget(self.DropList, 0, 0, 1, 1)

        self.modelDrag = QStringListModel()
        self.modelDrop = QStringListModel()
        self.DragList.setModel(self.modelDrag)
        self.DropList.setModel(self.modelDrop)
        self.DragList.setAlternatingRowColors(True)
        self.DragList.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.DropList.setAlternatingRowColors(True)
        self.DropList.setEditTriggers(QAbstractItemView.NoEditTriggers)

        # Combo items
        self.modelFreq = ComboModel(self.comboBoxFreq, 3, 1)
        self.modelFreq.addItem(self.tr("at the end of the calculation"), "end")
        self.modelFreq.addItem(self.tr("at each 'n' time steps"), "frequency")
        self.modelFreq.addItem(self.tr("Output every 'x' seconds"),
                               'time_value')

        self.modelFormat = ComboModel(self.comboBoxFormat, 2, 1)
        self.modelFormat.addItem(self.tr(".dat"), "DAT")
        self.modelFormat.addItem(self.tr(".csv"), "CSV")

        # Connections
        self.treeViewProfile.pressed[QModelIndex].connect(
            self.slotSelectProfile)
        self.pushButtonAdd.clicked.connect(self.slotAddProfile)
        self.pushButtonDelete.clicked.connect(self.slotDeleteProfile)
        self.pushButtonAddVar.clicked.connect(self.slotAddVarProfile)
        self.pushButtonSuppressVar.clicked.connect(self.slotDeleteVarProfile)
        self.comboBoxFreq.activated[str].connect(self.slotFrequencyType)
        self.comboBoxFormat.activated[str].connect(self.slotFormatType)
        self.pushButtonFormula.clicked.connect(self.slotFormula)
        self.lineEditBaseName.textChanged[str].connect(self.slotBaseName)
        self.lineEditFreq.textChanged[str].connect(self.slotFrequence)
        self.lineEditFreqTime.textChanged[str].connect(self.slotFrequenceTime)
        self.lineEditNbPoint.textChanged[str].connect(self.slotNbPoint)

        self.checkBoxSnapToCenter.clicked.connect(self.slotSnapToCenter)
        self.checkBoxActivateInterpolation.clicked.connect(
            self.slotActivateInterpolation)

        # Validators
        validatorFreq = IntValidator(self.lineEditFreq, min=0)
        validatorFreq.setExclusiveMin(True)
        self.lineEditFreq.setValidator(validatorFreq)

        validatorFreqT = DoubleValidator(self.lineEditFreqTime, min=0.)
        validatorFreqT.setExclusiveMin(True)
        self.lineEditFreqTime.setValidator(validatorFreqT)

        validatorNbPoint = IntValidator(self.lineEditNbPoint, min=0)
        self.lineEditNbPoint.setValidator(validatorNbPoint)

        rx = "[\-_A-Za-z0-9]{1," + str(LABEL_LENGTH_MAX) + "}"
        validatorBaseName = RegExpValidator(self.lineEditBaseName, QRegExp(rx))
        self.lineEditBaseName.setValidator(validatorBaseName)

        #update list of variables, properties, scalars ...
        liste_label = []
        for label in self.mdl.getVariablesAndVolumeProperties():
            liste_label.append(label)
        self.modelDrag.setStringList(sorted(liste_label, key=str.lower))

        #update list of profiles for view from xml file
        for lab in self.mdl.getProfilesLabelsList():
            self.entriesNumber = self.entriesNumber + 1
            label, fmt, lst, choice, freq, formula, nb_point = self.mdl.getProfileData(
                lab)
            self.__insertProfile(label, lst)

        self.__eraseEntries()

        self.case.undoStartGlobal()