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")
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()
def __setBoundary(self, boundary): """ Set the current boundary """ self.__boundary = boundary self.nature = boundary.getNature() self.therm = ThermalScalarModel(self.__case) self.sca_mo = DefineUserScalarsModel(self.__case) self.comp = CompressibleModel(self.__case) self.atm = AtmosphericFlowsModel(self.__case) self.modelTypeThermal = ComboModel(self.comboBoxTypeThermal, 1, 1) self.modelTypeSpecies = ComboModel(self.comboBoxTypeSpecies, 1, 1) self.modelTypeMeteo = ComboModel(self.comboBoxTypeMeteo, 1, 1) self.modelTypeThermal.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelTypeSpecies.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelTypeMeteo.addItem( self.tr("Prescribed value"), 'dirichlet') self.modelTypeThermal.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelTypeSpecies.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelTypeMeteo.addItem( self.tr("Prescribed value (user law)"), 'dirichlet_formula') if self.nature == 'outlet': self.modelTypeThermal.addItem(self.tr("Prescribed flux"), 'neumann') self.modelTypeSpecies.addItem(self.tr("Prescribed flux"), 'neumann') self.modelTypeMeteo.addItem( self.tr("Prescribed flux"), 'neumann') elif self.nature == 'wall': self.modelTypeThermal.addItem(self.tr("Prescribed flux"), 'neumann') self.modelTypeSpecies.addItem(self.tr("Prescribed flux"), 'neumann') self.modelTypeMeteo.addItem( self.tr("Prescribed flux"), 'neumann') self.modelTypeThermal.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') self.modelTypeSpecies.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') self.modelTypeMeteo.addItem( self.tr("Prescribed flux (user law)"), 'neumann_formula') self.modelTypeThermal.addItem(self.tr("Exchange coefficient"), 'exchange_coefficient') self.modelTypeSpecies.addItem(self.tr("Exchange coefficient"), 'exchange_coefficient') self.modelTypeMeteo.addItem( self.tr("Exchange coefficient"), 'exchange_coefficient') self.modelTypeThermal.addItem(self.tr("Exchange coefficient (user law)"), 'exchange_coefficient_formula') self.modelTypeSpecies.addItem(self.tr("Exchange coefficient (user law)"), 'exchange_coefficient_formula') self.modelTypeMeteo.addItem( self.tr("Exchange coefficient (user law)"), 'exchange_coefficient_formula') self.species = "" self.species_list = self.sca_mo.getUserScalarNameList() for s in self.sca_mo.getScalarsVarianceList(): if s in self.species_list: self.species_list.remove(s) self.species = "" if self.species_list != []: self.groupBoxSpecies.show() self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) for species in self.species_list: self.modelSpecies.addItem(self.tr(species), species) self.species = self.species_list[0] self.modelSpecies.setItem(str_model = self.species) else: self.groupBoxSpecies.hide() self.model_th = self.therm.getThermalScalarModel() if self.model_th != 'off' and self.comp.getCompressibleModel() == 'off': self.groupBoxThermal.show() self.modelThermal = ComboModel(self.comboBoxThermal,1,1) self.thermal = self.therm.getThermalScalarName() self.modelThermal.addItem(self.tr(self.thermal),self.thermal) self.modelThermal.setItem(str_model = self.thermal) else: self.groupBoxThermal.hide() self.meteo_list = "" self.meteo_list = self.sca_mo.getMeteoScalarsNameList() self.groupBoxMeteo.hide() if (self.atm.getAtmosphericFlowsModel() != "off" and self.nature == 'wall'): self.groupBoxThermal.hide() if (self.atm.getAtmosphericFlowsModel() != "off" and \ (self.nature == 'inlet' or self.nature == 'outlet')): label = self.__boundary.getLabel() nature = "meteo_" + self.nature bb = Boundary(nature, label, self.__case) if bb.getMeteoDataStatus() == 'off': self.groupBoxMeteo.hide() self.groupBoxThermal.show() self.modelMeteo = ComboModel(self.comboBoxMeteo, 1, 1) if len(self.meteo_list) > 0: self.groupBoxMeteo.show() for m in self.meteo_list: self.modelMeteo.addItem(self.tr(m), m) self.meteo = self.meteo_list[0] self.modelMeteo.setItem(str_model = self.meteo) else: self.groupBoxMeteo.hide() self.groupBoxThermal.hide() self.initializeVariables()
def initializeVariables(self): """ Initialize widget """ # Initalize exchange coef self.lineEditExThermal.hide() self.labelExThermal.hide() self.lineEditExSpecies.hide() self.labelExSpecies.hide() self.lineEditExMeteo.hide() self.labelExMeteo.hide() # Initalize thermal self.lineEditValueThermal.hide() self.labelValueThermal.hide() self.pushButtonThermal.setEnabled(False) setGreenColor(self.pushButtonThermal, False) if self.model_th != 'off' and self.comp.getCompressibleModel() == 'off': self.thermal_type = self.__boundary.getScalarChoice(self.thermal) self.modelTypeThermal.setItem(str_model = self.thermal_type) self.labelValueThermal.setText('Value') self.groupBoxThermal.setTitle('Thermal') if self.thermal_type in ('dirichlet', 'exchange_coefficient', 'neumann'): self.labelValueThermal.show() self.lineEditValueThermal.show() if self.thermal_type == 'exchange_coefficient': self.lineEditExThermal.show() self.labelExThermal.show() v = self.__boundary.getScalarValue(self.thermal, 'dirichlet') w = self.__boundary.getScalarValue(self.thermal, 'exchange_coefficient') self.lineEditValueThermal.setText(str(v)) self.lineEditExThermal.setText(str(w)) else: v = self.__boundary.getScalarValue(self.thermal, self.thermal_type) self.lineEditValueThermal.setText(str(v)) if self.thermal_type == 'neumann': self.labelValueThermal.setText('Flux') if self.nature == 'outlet': self.groupBoxThermal.setTitle('Thermal for backflow') elif self.thermal_type in ('exchange_coefficient_formula', 'dirichlet_formula', 'neumann_formula'): self.pushButtonThermal.setEnabled(True) setGreenColor(self.pushButtonThermal, True) # Initalize species self.labelValueSpecies.hide() self.lineEditValueSpecies.hide() self.pushButtonSpecies.setEnabled(False) setGreenColor(self.pushButtonSpecies, False) if self.species_list != None and self.species_list != []: self.species_type = self.__boundary.getScalarChoice(self.species) self.modelTypeSpecies.setItem(str_model = self.species_type) self.labelValueSpecies.setText('Value') self.groupBoxSpecies.setTitle('Species') if self.species_type in ('dirichlet', 'exchange_coefficient', 'neumann'): self.labelValueSpecies.show() self.lineEditValueSpecies.show() if self.species_type == 'exchange_coefficient': self.lineEditExSpecies.show() self.labelExSpecies.show() v = self.__boundary.getScalarValue(self.species, 'dirichlet') w = self.__boundary.getScalarValue(self.species, 'exchange_coefficient') self.lineEditValueSpecies.setText(str(v)) self.lineEditExSpecies.setText(str(w)) else: v = self.__boundary.getScalarValue(self.species, self.species_type) self.lineEditValueSpecies.setText(str(v)) if self.species_type == 'neumann': self.labelValueSpecies.setText('Flux') if self.nature == 'outlet': self.groupBoxSpecies.setTitle('Species for backflow') elif self.species_type in ('exchange_coefficient_formula', 'dirichlet_formula', 'neumann_formula'): self.pushButtonSpecies.setEnabled(True) setGreenColor(self.pushButtonSpecies, True) # Initalize meteo self.labelValueMeteo.hide() self.lineEditValueMeteo.hide() self.pushButtonMeteo.setEnabled(False) setGreenColor(self.pushButtonMeteo, False) if (self.meteo_list and (self.nature == 'inlet' or self.nature == 'outlet')): label = self.__boundary.getLabel() nature = "meteo_" + self.nature bb = Boundary(nature, label, self.__case) if bb.getMeteoDataStatus() == 'off': self.meteo_type = self.__boundary.getScalarChoice(self.meteo) self.modelTypeMeteo.setItem(str_model = self.meteo_type) self.labelValueMeteo.setText('Value') self.groupBoxMeteo.setTitle('Meteo') if self.meteo_type in ('dirichlet', 'exchange_coefficient', 'neumann'): self.labelValueMeteo.show() self.lineEditValueMeteo.show() if self.meteo_type == 'exchange_coefficient': self.lineEditExMeteo.show() self.labelExMeteo.show() v = self.__boundary.getScalarValue(self.meteo, 'dirichlet') w = self.__boundary.getScalarValue(self.meteo, 'exchange_coefficient') self.lineEditValueMeteo.setText(str(v)) self.lineEditExMeteo.setText(str(w)) else: v = self.__boundary.getScalarValue(self.meteo, self.meteo_type) self.lineEditValueMeteo.setText(str(v)) if self.meteo_type == 'neumann': self.labelValueMeteo.setText('Flux') if self.nature == 'outlet': self.groupBoxMeteo.setTitle('Meteo for backflow') if self.meteo_type in ('exchange_coefficient_formula', 'dirichlet_formula', 'neumann_formula'): self.pushButtonMeteo.setEnabled(True) setGreenColor(self.pushButtonMeteo, True)
class BoundaryConditionsMeteoView(QWidget, Ui_BoundaryConditionsMeteoForm): """ Boundary condifition for the velocity part """ def __init__(self, parent): """ Constructor. """ QWidget.__init__(self, parent) Ui_BoundaryConditionsMeteoForm.__init__(self) self.setupUi(self) def setup(self, case, velocityWidget, turbulenceWidget, scalarsWidget): """ Setup the widget. """ self.__case = case self.velocityWidget = velocityWidget self.turbulenceWidget = turbulenceWidget self.scalarsWidget = scalarsWidget self.__boundary = None sca_mo = DefineUserScalarsModel(self.__case) self.species_list = sca_mo.getUserScalarNameList() self.__case.undoStopGlobal() self.__model = AtmosphericFlowsModel(self.__case) self.connect(self.checkBoxReadData, SIGNAL("clicked(bool)"), self.__slotReadData) self.connect(self.checkBoxAutoNature, SIGNAL("clicked(bool)"), self.__slotAutoNature) self.__case.undoStartGlobal() def showWidget(self, b): """ Show the widget. """ self.__b = b if self.__model.getAtmosphericFlowsModel() != "off" \ and self.__model.getMeteoDataStatus() == "on": self.show() label = b.getLabel() nature = "meteo_" + b.getNature() self.__boundary = Boundary(nature, label, self.__case) if self.__boundary.getMeteoDataStatus() == 'on': self.checkBoxReadData.setChecked(True) self.checkBoxAutoNature.setEnabled(True) self.velocityWidget.hideWidget() self.turbulenceWidget.hideWidget() else: self.checkBoxReadData.setChecked(False) self.checkBoxAutoNature.setEnabled(False) if nature == "meteo_inlet": self.velocityWidget.showWidget(b) self.turbulenceWidget.showWidget(b) else: self.velocityWidget.hideWidget() self.turbulenceWidget.hideWidget() if self.__boundary.getAutomaticNatureStatus() == 'on': self.checkBoxAutoNature.setChecked(True) else: self.checkBoxAutoNature.setChecked(False) self.scalarsWidget.showWidget(self.__b) else: self.hideWidget() def hideWidget(self): """ Hide all. """ self.hide() def __slotReadData(self, bool): """ Input if the meteo data must be read. """ if bool == True: self.__boundary.setMeteoDataStatus('on') self.checkBoxAutoNature.setEnabled(True) self.velocityWidget.hideWidget() self.turbulenceWidget.hideWidget() else: self.__boundary.setMeteoDataStatus('off') self.checkBoxAutoNature.setChecked(False) self.__boundary.setAutomaticNatureStatus('off') self.checkBoxAutoNature.setEnabled(False) if self.__boundary.getNature() == "meteo_inlet": self.velocityWidget.showWidget(self.__b) self.turbulenceWidget.showWidget(self.__b) else: self.velocityWidget.hideWidget() self.turbulenceWidget.hideWidget() self.scalarsWidget.showWidget(self.__b) def __slotAutoNature(self, bool): """ Input if the nature of the boundary must be detected automaticaly. """ if bool == True: self.__boundary.setAutomaticNatureStatus('on') else: self.__boundary.setAutomaticNatureStatus('off') def tr(self, text): """ Translation. """ return text