def showWidget(self, boundary):
     """
     Show the widget
     """
     label = boundary.getLabel()
     self.__boundary = Boundary('compressible_outlet', label, self.__case)
     self.initialize()
 def showWidget(self, boundary):
     """
     Show the widget
     """
     label = boundary.getLabel()
     self.nature  = boundary.getNature()
     self.__boundary = Boundary(self.nature, label, self.__case)
     self.initialize()
 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)
         self.__updateView__()
         self.show()
     else:
         self.hideWidget()
Exemple #4
0
    def __slotSelectBoundary(self, index):
        """
        Select a boundary in the QTreeView.
        """
        label, codeNumber, nature, local = self.__modelBoundaries.getItem(
            index.row())
        log.debug("slotSelectBoundary label %s (%s)" % (label, nature))

        self.__hideAllWidgets()
        boundary = Boundary(nature, label, self.__case)

        if nature == 'wall':
            self.__selectWallBoundary(boundary)
        elif nature == 'inlet':
            self.__selectInletBoundary(boundary)
        elif nature == 'outlet':
            self.__selectOutletBoundary(boundary)
        elif nature == 'symmetry':
            self.__selectSymmetryBoundary(boundary)
        elif nature == 'free_inlet_outlet':
            self.__selectInletOutletBoundary(boundary)
        elif nature == 'imposed_p_outlet':
            self.__selectImposedPressureOutletBoundary(boundary)
        elif nature == 'groundwater':
            self.__selectGroundwaterBoundary(boundary)
    def showWidget(self, b):
        """
        Show the widget
        """
        label = b.getLabel()
        self.__boundary = Boundary('free_inlet_outlet', label, self.__case)
        exp = self.__boundary.getHeadLossesFormula()
        if exp:
            self.pushButtonHeadLossesFormula.setStyleSheet(
                "background-color: green")
            self.pushButtonHeadLossesFormula.setToolTip(exp)
        else:
            self.pushButtonHeadLossesFormula.setStyleSheet(
                "background-color: red")

        self.show()
    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()
class BoundaryConditionsWallRadiativeTransferView(
        QWidget, Ui_BoundaryConditionsWallRadiativeTransferForm):
    """
    """
    def __init__(self, parent):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_BoundaryConditionsWallRadiativeTransferForm.__init__(self)
        self.setupUi(self)

        validatorEmissivity = DoubleValidator(self.lineEditEmissivity, min=0.0)
        self.lineEditEmissivity.setValidator(validatorEmissivity)

        validatorConductivity = DoubleValidator(self.lineEditConductivity,
                                                min=0.0)
        self.lineEditConductivity.setValidator(validatorConductivity)

        validatorThickness = DoubleValidator(self.lineEditThickness, min=0.0)
        self.lineEditThickness.setValidator(validatorThickness)

        validatorExtTemperature = DoubleValidator(self.lineEditExtTemperature,
                                                  min=0.0)
        self.lineEditExtTemperature.setValidator(validatorExtTemperature)

        validatorIntTemperature = DoubleValidator(self.lineEditIntTemperature,
                                                  min=0.0)
        self.lineEditIntTemperature.setValidator(validatorIntTemperature)

        validatorConductionFlux = DoubleValidator(self.lineEditConductionFlux,
                                                  min=0.0)
        self.lineEditConductionFlux.setValidator(validatorConductionFlux)

    def __updateView__(self):
        cond = self.__boundary.getRadiativeChoice()

        #self.labelEmissivity.show()
        #self.lineEditEmissivity.show()
        self.lineEditEmissivity.setText(str(self.__boundary.getEmissivity()))

        #self.labelIntTemperature.hide()
        #self.lineEditIntTemperature.hide()
        #self.labelIntTemperatureUnit.hide()
        self.lineEditIntTemperature.setText(
            str(self.__boundary.getInternalTemperatureProfile()))

        self.labelConductivity.hide()
        self.lineEditConductivity.hide()
        self.labelConductivityUnit.hide()
        self.lineEditConductivity.setText(
            str(self.__boundary.getThermalConductivity()))

        self.labelThickness.hide()
        self.lineEditThickness.hide()
        self.labelThicknessUnit.hide()
        self.lineEditThickness.setText(str(self.__boundary.getThickness()))

        self.labelExtTemperature.hide()
        self.lineEditExtTemperature.hide()
        self.labelExtTemperatureUnit.hide()
        self.lineEditExtTemperature.setText(
            str(self.__boundary.getExternalTemperatureProfile()))

        self.labelConductionFlux.hide()
        self.lineEditConductionFlux.hide()
        self.labelConductionFluxUnit.hide()
        self.lineEditConductionFlux.setText(str(self.__boundary.getFlux()))

        if cond == 'ipgrno':
            self.labelConductivity.show()
            self.lineEditConductivity.show()
            self.labelConductivityUnit.show()

            self.labelThickness.show()
            self.lineEditThickness.show()
            self.labelThicknessUnit.show()

            self.labelExtTemperature.show()
            self.lineEditExtTemperature.show()
            self.labelExtTemperatureUnit.show()
        elif cond == 'ifgrno':
            self.labelConductionFlux.show()
            self.lineEditConductionFlux.show()
            self.labelConductionFluxUnit.show()

    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("Fixed interior temperature"),
                                    'itpimp')
        self.modelRadiative.addItem(self.tr("Fixed exterior temperature"),
                                    'ipgrno')
        self.modelRadiative.addItem(self.tr("Fixed conduction flux"), 'ifgrno')

        # Connections
        self.comboBoxRadiative.activated[str].connect(self.slotRadiativeChoice)

        self.lineEditEmissivity.textChanged[str].connect(self.slotEmissivity)
        self.lineEditConductivity.textChanged[str].connect(
            self.slotConductivity)
        self.lineEditThickness.textChanged[str].connect(self.slotThickness)
        self.lineEditExtTemperature.textChanged[str].connect(
            self.slotExtTemperature)
        self.lineEditIntTemperature.textChanged[str].connect(
            self.slotIntTemperature)
        self.lineEditConductionFlux.textChanged[str].connect(
            self.slotConductionFlux)

        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)
            self.__updateView__()
            self.show()
        else:
            self.hideWidget()

    def hideWidget(self):
        """
        Hide all the widget
        """
        self.hide()

    @pyqtSlot(str)
    def slotRadiativeChoice(self, text):
        cond = self.modelRadiative.dicoV2M[str(text)]
        log.debug("slotRadiativeChoice cond = %s " % cond)
        self.__boundary.setRadiativeChoice(cond)
        self.__updateView__()

    @pyqtSlot(str)
    def slotEmissivity(self, text):
        """
        """
        if self.lineEditEmissivity.validator().state == QValidator.Acceptable:
            c = from_qvariant(text, float)
            self.__boundary.setEmissivity(c)

    @pyqtSlot(str)
    def slotConductivity(self, text):
        """
        """
        if self.lineEditConductivity.validator(
        ).state == QValidator.Acceptable:
            c = from_qvariant(text, float)
            self.__boundary.setThermalConductivity(c)

    @pyqtSlot(str)
    def slotThickness(self, text):
        """
        """
        if self.lineEditThickness.validator().state == QValidator.Acceptable:
            c = from_qvariant(text, float)
            self.__boundary.setThickness(c)

    @pyqtSlot(str)
    def slotExtTemperature(self, text):
        """
        """
        if self.lineEditExtTemperature.validator(
        ).state == QValidator.Acceptable:
            c = from_qvariant(text, float)
            self.__boundary.setExternalTemperatureProfile(c)

    @pyqtSlot(str)
    def slotIntTemperature(self, text):
        """
        """
        if self.lineEditIntTemperature.validator(
        ).state == QValidator.Acceptable:
            c = from_qvariant(text, float)
            self.__boundary.setInternalTemperatureProfile(c)

    @pyqtSlot(str)
    def slotConductionFlux(self, text):
        """
        """
        if self.lineEditConductionFlux.validator(
        ).state == QValidator.Acceptable:
            c = from_qvariant(text, float)
            self.__boundary.setFlux(c)

    def tr(self, text):
        """
        Translation
        """
        return text
class BoundaryConditionsCompressibleOutletView(
        QWidget, Ui_BoundaryConditionsCompressibleOutletForm):
    def __init__(self, parent):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_BoundaryConditionsCompressibleOutletForm.__init__(self)
        self.setupUi(self)

    def setup(self, case):
        """
        Setup the widget
        """
        self.__case = case
        self.__boundary = None

        self.__case.undoStopGlobal()

        self.mdl = CompressibleModel(self.__case)

        # Connections
        self.comboBoxTypeOutlet.activated[str].connect(self.slotOutletType)
        self.lineEditPressure.textChanged[str].connect(self.slotPressureValue)

        # Combo models
        self.modelTypeOutlet = ComboModel(self.comboBoxTypeOutlet, 2, 1)
        self.modelTypeOutlet.addItem(self.tr("supersonic outlet"),
                                     'supersonic_outlet')
        self.modelTypeOutlet.addItem(self.tr("subsonic outlet"),
                                     'subsonic_outlet')

        # Validators
        validatorP = DoubleValidator(self.lineEditPressure, min=0.0)

        # Apply validators
        self.lineEditPressure.setValidator(validatorP)

        self.__case.undoStartGlobal()

    def showWidget(self, boundary):
        """
        Show the widget
        """
        label = boundary.getLabel()
        self.__boundary = Boundary('compressible_outlet', label, self.__case)
        self.initialize()

    def initialize(self):

        # Initialize thermodynamic value

        outlet_type = self.__boundary.getOutletType()
        self.modelTypeOutlet.setItem(str_model=outlet_type)
        self.__boundary.setOutletType(outlet_type)
        if outlet_type == 'supersonic_outlet':
            self.frameDensity.hide()
        else:
            self.frameDensity.show()
            pressure = self.__boundary.getPressureValue()
            self.lineEditPressure.setText(str(pressure))

        self.show()

    def hideWidget(self):
        """
        Hide all
        """
        self.hide()

    @pyqtSlot(str)
    def slotOutletType(self, text):
        """
        INPUT outlet type
        """
        value = self.modelTypeOutlet.dicoV2M[str(text)]
        log.debug("__slotOutletType value = %s " % value)

        self.__boundary.setOutletType(value)
        self.initialize()

    @pyqtSlot(str)
    def slotPressureValue(self, text):
        """
        INPUT outlet pressure
        """
        if self.sender().validator().state == QValidator.Acceptable:
            t = from_qvariant(text, float)
            self.__boundary.setPressureValue(t)

    def getCompressibleModel(self):
        """
        Return the compressible model
        """
        model = self.mdl.getCompressibleModel()
        return model

    def tr(self, text):
        """
        Translation
        """
        return text
class BoundaryConditionsHydraulicHeadView(QWidget, Ui_BoundaryConditionsHydraulicHeadForm):
    def __init__(self, parent):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_BoundaryConditionsHydraulicHeadForm.__init__(self)
        self.setupUi(self)


    def setup(self, case):
        """
        Setup the widget
        """
        self.__case = case
        self.__boundary = None
        self.notebook = NotebookModel(self.__case)

        self.__case.undoStopGlobal()

        # Validators
        validatorHh   = DoubleValidator(self.lineEditValueHydraulicHead)
        validatorExHh = DoubleValidator(self.lineEditExHydraulicHead)

        # Apply validators
        self.lineEditValueHydraulicHead.setValidator(validatorHh)
        self.lineEditExHydraulicHead.setValidator(validatorHh)

        self.modelTypeHydraulic = ComboModel(self.comboBoxTypeHydraulicHead, 1, 1)
        self.modelTypeHydraulic.addItem(self.tr("Prescribed value"), 'dirichlet')
        self.modelTypeHydraulic.addItem(self.tr("Prescribed value  (user law)"), 'dirichlet_formula')
        self.modelTypeHydraulic.addItem(self.tr("Prescribed flux"), 'neumann')

        # Connections
        self.lineEditValueHydraulicHead.textChanged[str].connect(self.slotHydraulicHeadValue)
        self.lineEditExHydraulicHead.textChanged[str].connect(self.slotHydraulicHeadFlux)
        self.pushButtonHydraulicHead.clicked.connect(self.slotHydraulicHeadFormula)
        self.comboBoxTypeHydraulicHead.activated[str].connect(self.slotHydraulicHeadChoice)

        self.__case.undoStartGlobal()


    def showWidget(self, boundary):
        """
        Show the widget
        """
        label = boundary.getLabel()
        self.nature  = boundary.getNature()
        self.__boundary = Boundary(self.nature, label, self.__case)
        self.initialize()


    def initialize(self):
        self.labelValueHydraulicHead.hide()
        self.labelExHydraulicHead.hide()
        self.lineEditValueHydraulicHead.hide()
        self.lineEditExHydraulicHead.hide()
        self.pushButtonHydraulicHead.setEnabled(False)
        self.pushButtonHydraulicHead.setStyleSheet("background-color: None")

        HydraulicChoice = self.__boundary.getHydraulicHeadChoice()
        self.modelTypeHydraulic.setItem(str_model = HydraulicChoice)
        if HydraulicChoice == 'dirichlet':
            self.labelValueHydraulicHead.show()
            self.lineEditValueHydraulicHead.show()
            h_head = self.__boundary.getHydraulicHeadValue()
            self.lineEditValueHydraulicHead.setText(str(h_head))
        elif HydraulicChoice == 'neumann':
            self.labelExHydraulicHead.show()
            self.lineEditExHydraulicHead.show()
            h_head = self.__boundary.getHydraulicHeadFlux()
            self.lineEditExHydraulicHead.setText(str(h_head))
        elif HydraulicChoice == 'dirichlet_formula':
            self.pushButtonHydraulicHead.setEnabled(True)

            exp = self.__boundary.getHydraulicHeadFormula()
            if exp:
                self.pushButtonHydraulicHead.setStyleSheet("background-color: green")
                self.pushButtonHydraulicHead.setToolTip(exp)
            else:
                self.pushButtonHydraulicHead.setStyleSheet("background-color: red")

        self.show()


    def hideWidget(self):
        """
        Hide all
        """
        self.hide()


    @pyqtSlot(str)
    def slotHydraulicHeadValue(self, text):
        """
        INPUT hydraulic head value
        """
        if self.lineEditValueHydraulicHead.validator().state == QValidator.Acceptable:
            t = from_qvariant(text, float)
            self.__boundary.setHydraulicHeadValue(t)


    @pyqtSlot(str)
    def slotHydraulicHeadFlux(self, text):
        """
        INPUT hydraulic head flux
        """
        if self.lineEditExHydraulicHead.validator().state == QValidator.Acceptable:
            t = from_qvariant(text, float)
            self.__boundary.setHydraulicHeadFlux(t)


    @pyqtSlot()
    def slotHydraulicHeadFormula(self):
        """
        """
        exp = self.__boundary.getHydraulicHeadFormula()
        exa = """#example: """
        req = [("H", "hydraulic head")]

        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')]

        for (nme, val) in self.notebook.getNotebookList():
            sym.append((nme, 'value (notebook) = ' + str(val)))

        dialog = QMeiEditorView(self,
                                check_syntax = self.__case['package'].get_check_syntax(),
                                expression = exp,
                                required   = req,
                                symbols    = sym,
                                examples   = exa)
        if dialog.exec_():
            result = dialog.get_result()
            log.debug("slotHydraulicHeadFormula -> %s" % str(result))
            self.__boundary.setHydraulicHeadFormula(str(result))
            self.pushButtonHydraulicHead.setStyleSheet("background-color: green")
            self.pushButtonHydraulicHead.setToolTip(result)


    @pyqtSlot(str)
    def slotHydraulicHeadChoice(self, text):
        """
        INPUT label for choice of zone
        """
        HydraulicChoice = self.modelTypeHydraulic.dicoV2M[str(text)]
        self.__boundary.setHydraulicHeadChoice(HydraulicChoice)
        self.initialize()


    def tr(self, text):
        """
        Translation
        """
        return text
class BoundaryConditionsPressureView(QWidget,
                                     Ui_BoundaryConditionsPressureForm):
    def __init__(self, parent):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_BoundaryConditionsPressureForm.__init__(self)
        self.setupUi(self)

    def setup(self, case):
        """
        Setup the widget
        """
        self.__case = case
        self.__boundary = None

        self.__case.undoStopGlobal()

        # Connections
        self.lineEditPressure.textChanged[str].connect(self.slotPressureValue)

        # Validators
        validatorP = DoubleValidator(self.lineEditPressure, min=0.0)

        # Apply validators
        self.lineEditPressure.setValidator(validatorP)

        self.__case.undoStartGlobal()

    def showWidget(self, boundary):
        """
        Show the widget
        """
        label = boundary.getLabel()
        self.nature = boundary.getNature()
        self.__boundary = Boundary(self.nature, label, self.__case)
        self.initialize()

    def initialize(self):

        # Initialize thermodynamic value
        pressure = self.__boundary.getPressureValue()
        self.lineEditPressure.setText(str(pressure))

        self.show()

    def hideWidget(self):
        """
        Hide all
        """
        self.hide()

    @pyqtSlot(str)
    def slotPressureValue(self, text):
        """
        INPUT outlet pressure
        """
        if self.sender().validator().state == QValidator.Acceptable:
            t = from_qvariant(text, float)
            self.__boundary.setPressureValue(t)

    def tr(self, text):
        """
        Translation
        """
        return text
class BoundaryConditionsExternalHeadLossesView(
        QWidget, Ui_BoundaryConditionsExternalHeadLossesForm):
    def __init__(self, parent):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_BoundaryConditionsExternalHeadLossesForm.__init__(self)
        self.setupUi(self)

    def setup(self, case):
        """
        Setup the widget
        """
        self.__case = case
        self.__boundary = None
        self.notebook = NotebookModel(self.__case)

        self.__case.undoStopGlobal()

        self.pushButtonHeadLossesFormula.clicked.connect(
            self.slotHeadLossesFormula)

        self.__case.undoStartGlobal()

    def showWidget(self, b):
        """
        Show the widget
        """
        label = b.getLabel()
        self.__boundary = Boundary('free_inlet_outlet', label, self.__case)
        exp = self.__boundary.getHeadLossesFormula()
        if exp:
            self.pushButtonHeadLossesFormula.setStyleSheet(
                "background-color: green")
            self.pushButtonHeadLossesFormula.setToolTip(exp)
        else:
            self.pushButtonHeadLossesFormula.setStyleSheet(
                "background-color: red")

        self.show()

    def hideWidget(self):
        """
        Hide all
        """
        self.hide()

    @pyqtSlot()
    def slotHeadLossesFormula(self):
        """
        """
        exp = self.__boundary.getHeadLossesFormula()
        if not exp:
            exp = "K = 0.;"

        req = [('K', 'External head losses')]

        exa = "K = 0.;"

        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')]

        for (nme, val) in self.notebook.getNotebookList():
            sym.append((nme, 'value (notebook) = ' + str(val)))

        dialog = QMeiEditorView(
            self,
            check_syntax=self.__case['package'].get_check_syntax(),
            expression=exp,
            required=req,
            symbols=sym,
            examples=exa)
        if dialog.exec_():
            result = dialog.get_result()
            log.debug("slotFormulaDirection -> %s" % str(result))
            self.__boundary.setHeadLossesFormula(str(result))
            self.pushButtonHeadLossesFormula.setStyleSheet(
                "background-color: green")
            self.pushButtonHeadLossesFormula.setToolTip(result)

    def tr(self, text):
        """
        Translation
        """
        return text
Exemple #12
0
    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)
        self.pushButtonThermal.setStyleSheet("background-color: None")

        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)
                exp = self.__boundary.getScalarFormula(self.thermal,
                                                       self.thermal_type)
                if exp:
                    self.pushButtonThermal.setStyleSheet(
                        "background-color: green")
                    self.pushButtonThermal.setToolTip(exp)
                else:
                    self.pushButtonThermal.setStyleSheet(
                        "background-color: red")

        # Initalize species
        self.labelValueSpecies.hide()
        self.lineEditValueSpecies.hide()
        self.pushButtonSpecies.setEnabled(False)
        self.pushButtonSpecies.setStyleSheet("background-color: None")

        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')
                    if self.nature == 'groundwater':
                        self.labelValueSpecies.setText('Velocity')
                        self.labelExSpecies.setText('Concentration')
                    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)
                exp = self.__boundary.getScalarFormula(self.species,
                                                       self.species_type)
                if exp:
                    self.pushButtonSpecies.setStyleSheet(
                        "background-color: green")
                    self.pushButtonSpecies.setToolTip(exp)
                else:
                    self.pushButtonSpecies.setStyleSheet(
                        "background-color: red")

            if self.nature == 'groundwater':
                self.groupBoxSpecies.setTitle('Transport equation')

        # Initalize meteo
        self.labelValueMeteo.hide()
        self.lineEditValueMeteo.hide()
        self.pushButtonMeteo.setEnabled(False)
        self.pushButtonMeteo.setStyleSheet("background-color: None")

        if (self.meteo_list):
            label = self.__boundary.getLabel()
            if self.nature != 'wall':
                nature = "meteo_" + self.nature
            else:
                nature = self.nature
            bb = Boundary(nature, label, self.__case)

            if self.nature == 'wall' or 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)
                    exp = self.__boundary.getScalarFormula(
                        self.meteo, self.meteo_type)
                    if exp:
                        self.pushButtonMeteo.setStyleSheet(
                            "background-color: green")
                        self.pushButtonMeteo.setToolTip(exp)
                    else:
                        self.pushButtonMeteo.setStyleSheet(
                            "background-color: red")
Exemple #13
0
    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 (outgoing) flux"), 'neumann')
            self.modelTypeSpecies.addItem(
                self.tr("Prescribed (outgoing) flux"), 'neumann')
            self.modelTypeMeteo.addItem(self.tr("Prescribed (outgoing) flux"),
                                        'neumann')
        elif self.nature == 'wall':
            self.modelTypeThermal.addItem(
                self.tr("Prescribed (outgoing) flux"), 'neumann')
            self.modelTypeSpecies.addItem(
                self.tr("Prescribed (outgoing) flux"), 'neumann')
            self.modelTypeMeteo.addItem(self.tr("Prescribed (outgoing) flux"),
                                        'neumann')
            self.modelTypeThermal.addItem(
                self.tr("Prescribed (outgoing) flux (user law)"),
                'neumann_formula')
            self.modelTypeSpecies.addItem(
                self.tr("Prescribed (outgoing) flux (user law)"),
                'neumann_formula')
            self.modelTypeMeteo.addItem(
                self.tr("Prescribed (outgoing) 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')
        elif self.nature == 'groundwater':
            self.modelTypeSpecies.addItem(
                self.tr("Prescribed (outgoing) flux"), 'neumann')

        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.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)

        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()