Beispiel #1
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")
Beispiel #2
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()