def setInitialValues(self): for i in range(len(self.obj.partNameList)): self.form.listWidget.addItem(str(self.obj.partNameList[i])) if self.obj.Name.startswith('PorousZone'): ci = indexOrDefault(POROUS_CORRELATIONS, self.p.get('PorousCorrelation'), 0) self.form.comboBoxCorrelation.setCurrentIndex(ci) d = self.p.get('D') setInputFieldQuantity(self.form.dx, "{} m^-2".format(d[0])) setInputFieldQuantity(self.form.dy, "{} m^-2".format(d[1])) setInputFieldQuantity(self.form.dz, "{} m^-2".format(d[2])) f = self.p.get('F') setInputFieldQuantity(self.form.fx, "{} m^-1".format(f[0])) setInputFieldQuantity(self.form.fy, "{} m^-1".format(f[1])) setInputFieldQuantity(self.form.fz, "{} m^-1".format(f[2])) e1 = self.p.get('e1') setInputFieldQuantity(self.form.e1x, str(e1[0])) setInputFieldQuantity(self.form.e1y, str(e1[1])) setInputFieldQuantity(self.form.e1z, str(e1[2])) e2 = self.p.get('e2') setInputFieldQuantity(self.form.e2x, str(e2[0])) setInputFieldQuantity(self.form.e2y, str(e2[1])) setInputFieldQuantity(self.form.e2z, str(e2[2])) e3 = self.p.get('e3') setInputFieldQuantity(self.form.e3x, str(e3[0])) setInputFieldQuantity(self.form.e3y, str(e3[1])) setInputFieldQuantity(self.form.e3z, str(e3[2])) setInputFieldQuantity(self.form.inputOuterDiameter, "{} m".format(self.p.get('OuterDiameter'))) tubeAxis = self.p.get('TubeAxis') setInputFieldQuantity(self.form.inputTubeAxisX, str(tubeAxis[0])) setInputFieldQuantity(self.form.inputTubeAxisY, str(tubeAxis[1])) setInputFieldQuantity(self.form.inputTubeAxisZ, str(tubeAxis[2])) setInputFieldQuantity(self.form.inputTubeSpacing, "{} m".format(self.p.get('TubeSpacing'))) normalAxis = self.p.get('SpacingDirection') setInputFieldQuantity(self.form.inputBundleLayerNormalX, str(normalAxis[0])) setInputFieldQuantity(self.form.inputBundleLayerNormalY, str(normalAxis[1])) setInputFieldQuantity(self.form.inputBundleLayerNormalZ, str(normalAxis[2])) setInputFieldQuantity(self.form.inputAspectRatio, str(self.p.get('AspectRatio'))) setInputFieldQuantity(self.form.inputVelocityEstimate, "{} m/s".format(self.p.get('VelocityEstimate'))) elif self.obj.Name.startswith('InitialisationZone'): if 'Ux' in self.p: setInputFieldQuantity(self.form.inputUx, "{} m/s".format(self.p.get('Ux'))) setInputFieldQuantity(self.form.inputUy, "{} m/s".format(self.p.get('Uy'))) setInputFieldQuantity(self.form.inputUz, "{} m/s".format(self.p.get('Uz'))) self.form.checkVelocity.setChecked(True) if 'Pressure' in self.p: setInputFieldQuantity(self.form.inputPressure, "{} kg/m/s^2".format(self.p.get('Pressure'))) self.form.checkPressure.setChecked(True) if 'alphas' in self.p: self.form.checkAlpha.setChecked(True) # Simulate initial signals to get into correct state self.checkVelocityChanged(self.form.checkVelocity.isChecked()) self.checkPressureChanged(self.form.checkPressure.isChecked()) self.checkAlphaChanged(self.form.checkAlpha.isChecked())
def setInitialValues(self): for i in range(len(self.obj.partNameList)): self.form.listWidget.addItem(str(self.obj.partNameList[i])) if "PorousZone" in self.obj.Name: ci = indexOrDefault(POROUS_CORRELATIONS, self.p.get('PorousCorrelation'), 0) self.form.comboBoxCorrelation.setCurrentIndex(ci) d = self.p.get('D') self.form.dx.setText("{}".format(d[0])) self.form.dy.setText("{}".format(d[1])) self.form.dz.setText("{}".format(d[2])) f = self.p.get('F') self.form.fx.setText("{}".format(f[0])) self.form.fy.setText("{}".format(f[1])) self.form.fz.setText("{}".format(f[2])) e1 = self.p.get('e1') self.form.e1x.setText("{}".format(e1[0])) self.form.e1y.setText("{}".format(e1[1])) self.form.e1z.setText("{}".format(e1[2])) e2 = self.p.get('e2') self.form.e2x.setText("{}".format(e2[0])) self.form.e2y.setText("{}".format(e2[1])) self.form.e2z.setText("{}".format(e2[2])) e3 = self.p.get('e3') self.form.e3x.setText("{}".format(e3[0])) self.form.e3y.setText("{}".format(e3[1])) self.form.e3z.setText("{}".format(e3[2])) self.form.inputOuterDiameter.setText("{} mm".format( self.p.get('OuterDiameter') * 1000)) tubeAxis = self.p.get('TubeAxis') self.form.inputTubeAxisX.setText("{}".format(tubeAxis[0])) self.form.inputTubeAxisY.setText("{}".format(tubeAxis[1])) self.form.inputTubeAxisZ.setText("{}".format(tubeAxis[2])) self.form.inputTubeSpacing.setText("{} mm".format( self.p.get('TubeSpacing') * 1000)) normalAxis = self.p.get('SpacingDirection') self.form.inputBundleLayerNormalX.setText("{}".format( normalAxis[0])) self.form.inputBundleLayerNormalY.setText("{}".format( normalAxis[1])) self.form.inputBundleLayerNormalZ.setText("{}".format( normalAxis[2])) self.form.inputAspectRatio.setText("{}".format( self.p.get('AspectRatio'))) self.form.inputVelocityEstimate.setText("{} m/s".format( self.p.get('VelocityEstimate')))
def load(self): if self.obj.Name.startswith('PorousZone'): ci = indexOrDefault(CfdZone.POROUS_CORRELATIONS, self.obj.PorousCorrelation, 0) self.form.comboBoxCorrelation.setCurrentIndex(ci) setQuantity(self.form.dx, self.obj.D1) setQuantity(self.form.dy, self.obj.D2) setQuantity(self.form.dz, self.obj.D3) setQuantity(self.form.fx, self.obj.F1) setQuantity(self.form.fy, self.obj.F2) setQuantity(self.form.fz, self.obj.F3) e1 = self.obj.e1 setQuantity(self.form.e1x, str(e1[0])) setQuantity(self.form.e1y, str(e1[1])) setQuantity(self.form.e1z, str(e1[2])) e2 = self.obj.e2 setQuantity(self.form.e2x, str(e2[0])) setQuantity(self.form.e2y, str(e2[1])) setQuantity(self.form.e2z, str(e2[2])) e3 = self.obj.e3 setQuantity(self.form.e3x, str(e3[0])) setQuantity(self.form.e3y, str(e3[1])) setQuantity(self.form.e3z, str(e3[2])) setQuantity(self.form.inputOuterDiameter, self.obj.OuterDiameter) tubeAxis = self.obj.TubeAxis setQuantity(self.form.inputTubeAxisX, str(tubeAxis[0])) setQuantity(self.form.inputTubeAxisY, str(tubeAxis[1])) setQuantity(self.form.inputTubeAxisZ, str(tubeAxis[2])) setQuantity(self.form.inputTubeSpacing, self.obj.TubeSpacing) normalAxis = self.obj.SpacingDirection setQuantity(self.form.inputBundleLayerNormalX, str(normalAxis[0])) setQuantity(self.form.inputBundleLayerNormalY, str(normalAxis[1])) setQuantity(self.form.inputBundleLayerNormalZ, str(normalAxis[2])) setQuantity(self.form.inputAspectRatio, self.obj.AspectRatio) setQuantity(self.form.inputVelocityEstimate, self.obj.VelocityEstimate) elif self.obj.Name.startswith('InitialisationZone'): self.form.checkVelocity.setChecked(self.obj.VelocitySpecified) setQuantity(self.form.inputUx, self.obj.Ux) setQuantity(self.form.inputUy, self.obj.Uy) setQuantity(self.form.inputUz, self.obj.Uz) self.form.checkPressure.setChecked(self.obj.PressureSpecified) setQuantity(self.form.inputPressure, self.obj.Pressure) self.form.checkAlpha.setChecked(self.obj.VolumeFractionSpecified) self.alphas = self.obj.VolumeFractions
def setInitialValues(self): """ Populate UI, update view from settings""" self.form.comboBoundaryType.addItems(BOUNDARY_NAMES) bi = indexOrDefault(BOUNDARY_TYPES, self.BoundarySettingsOrig.get('BoundaryType'), 0) self.form.comboBoundaryType.setCurrentIndex(bi) si = indexOrDefault(SUBTYPES[bi], self.BoundarySettingsOrig.get('BoundarySubtype'), 0) self.form.comboSubtype.setCurrentIndex(si) cart = self.BoundarySettings.get('VelocityIsCartesian', False) self.form.radioButtonCart.setChecked(cart) self.form.radioButtonMagNormal.setChecked(not cart) setInputFieldQuantity(self.form.inputCartX, str(self.BoundarySettings.get('Ux')) + "m/s") setInputFieldQuantity(self.form.inputCartY, str(self.BoundarySettings.get('Uy')) + "m/s") setInputFieldQuantity(self.form.inputCartZ, str(self.BoundarySettings.get('Uz')) + "m/s") setInputFieldQuantity( self.form.inputVelocityMag, str(self.BoundarySettings.get('VelocityMag')) + "m/s") self.form.lineDirection.setText( self.BoundarySettings.get('DirectionFace')) self.form.checkReverse.setChecked( bool(self.BoundarySettings.get('ReverseNormal'))) setInputFieldQuantity( self.form.inputPressure, str(self.BoundarySettings.get('Pressure')) + "kg/m/s^2") setInputFieldQuantity(self.form.inputSlipRatio, str(self.BoundarySettings.get('SlipRatio'))) setInputFieldQuantity( self.form.inputVolFlowRate, str(self.BoundarySettings.get('VolFlowRate')) + "m^3/s") setInputFieldQuantity( self.form.inputMassFlowRate, str(self.BoundarySettings.get('MassFlowRate')) + "kg/s") buttonId = self.BoundarySettings.get('PorousBaffleMethod', 0) selButton = self.form.buttonGroupPorous.button(buttonId) if selButton is not None: selButton.setChecked(True) self.buttonGroupPorousClicked( selButton) # Signal is not generated on setChecked above setInputFieldQuantity( self.form.inputPressureDropCoeff, str(self.BoundarySettings.get('PressureDropCoeff'))) setInputFieldQuantity( self.form.inputWireDiameter, str(self.BoundarySettings.get('ScreenWireDiameter')) + "m") setInputFieldQuantity( self.form.inputSpacing, str(self.BoundarySettings.get('ScreenSpacing')) + "m") self.form.comboThermalBoundaryType.addItems(THERMAL_BOUNDARY_NAMES) thi = indexOrDefault( THERMAL_BOUNDARY_TYPES, self.BoundarySettingsOrig.get('ThermalBoundaryType'), 0) self.form.comboThermalBoundaryType.setCurrentIndex(thi) setInputFieldQuantity( self.form.inputTemperature, str(self.BoundarySettings.get('Temperature', 273.0)) + "K") setInputFieldQuantity( self.form.inputHeatFlux, str(self.BoundarySettings.get('HeatFlux', 0.0)) + "W/m^2") setInputFieldQuantity( self.form.inputHeatTransferCoeff, str(self.BoundarySettings.get('HeatTransferCoeff', 0.0)) + "W/m^2/K") if self.turbModel is not None: self.form.comboTurbulenceSpecification.addItems( TURBULENT_INLET_SPEC[self.turbModel][0]) ti = indexOrDefault( TURBULENT_INLET_SPEC[self.turbModel][1], self.BoundarySettingsOrig.get('TurbulenceInletSpecification'), 0) self.form.comboTurbulenceSpecification.setCurrentIndex(ti) # Add volume fraction fields if len(self.material_objs) > 1: mat_names = [] for m in self.material_objs: mat_names.append(m.Label) self.form.comboFluid.clear() self.form.comboFluid.addItems(mat_names[:-1]) else: self.form.comboFluid.clear() setInputFieldQuantity( self.form.inputKineticEnergy, str(self.BoundarySettings.get('TurbulentKineticEnergy')) + "m^2/s^2") setInputFieldQuantity( self.form.inputSpecificDissipationRate, str(self.BoundarySettings.get('SpecificDissipationRate')) + "rad/s") setInputFieldQuantity( self.form.inputIntensity, str(self.BoundarySettings.get('TurbulenceIntensity'))) setInputFieldQuantity( self.form.inputLengthScale, str(self.BoundarySettings.get('TurbulenceLengthScale')) + "m")
def __init__(self, obj, physics_model, material_objs): self.selecting_direction = False self.obj = obj self.physics_model = physics_model self.turbModel = (physics_model.TurbulenceModel if physics_model.Turbulence == 'RANS' or physics_model.Turbulence == 'LES' else None) self.material_objs = material_objs # Store values which are changed on the fly for visual update self.ReferencesOrig = list(self.obj.References) self.BoundaryTypeOrig = str(self.obj.BoundaryType) self.BoundarySubTypeOrig = str(self.obj.BoundarySubType) self.alphas = {} ui_path = os.path.join(os.path.dirname(__file__), "TaskPanelCfdFluidBoundary.ui") self.form = FreeCADGui.PySideUic.loadUi(ui_path) self.form.buttonDirection.setCheckable(True) # Annoyingly can't find a way to set ID's for button group from .ui file... self.form.buttonGroupPorous.setId(self.form.radioButtonPorousCoeff, 0) self.form.buttonGroupPorous.setId(self.form.radioButtonPorousScreen, 1) self.form.comboBoundaryType.addItems(CfdFluidBoundary.BOUNDARY_NAMES) bi = indexOrDefault(CfdFluidBoundary.BOUNDARY_TYPES, self.obj.BoundaryType, 0) self.form.comboBoundaryType.currentIndexChanged.connect( self.comboBoundaryTypeChanged) self.form.comboBoundaryType.setCurrentIndex(bi) self.comboBoundaryTypeChanged() si = indexOrDefault(CfdFluidBoundary.SUBTYPES[bi], self.obj.BoundarySubType, 0) self.form.comboSubtype.currentIndexChanged.connect( self.comboSubtypeChanged) self.form.comboSubtype.setCurrentIndex(si) self.comboSubtypeChanged() cart = self.obj.VelocityIsCartesian self.form.radioButtonCart.setChecked(cart) self.form.radioButtonMagNormal.setChecked(not cart) setQuantity(self.form.inputCartX, self.obj.Ux) setQuantity(self.form.inputCartY, self.obj.Uy) setQuantity(self.form.inputCartZ, self.obj.Uz) setQuantity(self.form.inputVelocityMag, self.obj.VelocityMag) self.form.lineDirection.setText(self.obj.DirectionFace) self.form.checkReverse.setChecked(self.obj.ReverseNormal) setQuantity(self.form.inputPressure, self.obj.Pressure) setQuantity(self.form.inputSlipRatio, self.obj.SlipRatio) setQuantity(self.form.inputVolFlowRate, self.obj.VolFlowRate) setQuantity(self.form.inputMassFlowRate, self.obj.MassFlowRate) buttonId = indexOrDefault(CfdFluidBoundary.POROUS_METHODS, self.obj.PorousBaffleMethod, 0) selButton = self.form.buttonGroupPorous.button(buttonId) if selButton is not None: selButton.setChecked(True) setQuantity(self.form.inputPressureDropCoeff, self.obj.PressureDropCoeff) setQuantity(self.form.inputWireDiameter, self.obj.ScreenWireDiameter) setQuantity(self.form.inputSpacing, self.obj.ScreenSpacing) self.form.comboThermalBoundaryType.addItems( CfdFluidBoundary.THERMAL_BOUNDARY_NAMES) thi = indexOrDefault(CfdFluidBoundary.THERMAL_BOUNDARY_TYPES, self.obj.ThermalBoundaryType, 0) self.form.comboThermalBoundaryType.setCurrentIndex(thi) setQuantity(self.form.inputTemperature, self.obj.Temperature) setQuantity(self.form.inputHeatFlux, self.obj.HeatFlux) setQuantity(self.form.inputHeatTransferCoeff, self.obj.HeatTransferCoeff) if self.turbModel is not None: self.form.comboTurbulenceSpecification.addItems( CfdFluidBoundary.TURBULENT_INLET_SPEC[self.turbModel][0]) ti = indexOrDefault( CfdFluidBoundary.TURBULENT_INLET_SPEC[self.turbModel][1], self.obj.TurbulenceInletSpecification, 0) self.form.comboTurbulenceSpecification.setCurrentIndex(ti) # Add volume fraction fields self.alphas = self.obj.VolumeFractions if len(self.material_objs) > 1: mat_names = [] for m in self.material_objs: mat_names.append(m.Label) self.form.comboFluid.clear() self.form.comboFluid.addItems(mat_names[:-1]) self.comboFluidChanged(self.form.comboFluid.currentIndex()) else: self.form.comboFluid.clear() setQuantity(self.form.inputKineticEnergy, self.obj.TurbulentKineticEnergy) setQuantity(self.form.inputSpecificDissipationRate, self.obj.SpecificDissipationRate) setQuantity(self.form.inputIntensity, self.obj.TurbulenceIntensity) setQuantity(self.form.inputLengthScale, self.obj.TurbulenceLengthScale) self.form.radioButtonCart.toggled.connect(self.updateUI) self.form.radioButtonMagNormal.toggled.connect(self.updateUI) self.form.lineDirection.textChanged.connect(self.lineDirectionChanged) self.form.buttonDirection.clicked.connect(self.buttonDirectionClicked) self.form.buttonGroupPorous.buttonClicked.connect(self.updateUI) self.form.comboTurbulenceSpecification.currentIndexChanged.connect( self.updateUI) self.form.comboFluid.currentIndexChanged.connect( self.comboFluidChanged) self.form.inputVolumeFraction.valueChanged.connect( self.inputVolumeFractionChanged) self.form.comboThermalBoundaryType.currentIndexChanged.connect( self.updateUI) # Face list selection panel - modifies obj.References passed to it self.faceSelector = CfdFaceSelectWidget.CfdFaceSelectWidget( self.form.faceSelectWidget, self.obj, True, False) self.updateUI()
def setInitialValues(self): """ Populate UI """ self.form.comboBoundaryType.addItems(BOUNDARY_NAMES) bi = indexOrDefault(BOUNDARY_TYPES, self.BoundarySettingsOrig.get('BoundaryType'), 0) self.form.comboBoundaryType.setCurrentIndex(bi) si = indexOrDefault(SUBTYPES[bi], self.BoundarySettingsOrig.get('BoundarySubtype'), 0) self.form.comboSubtype.setCurrentIndex(si) self.rebuild_list_references() cart = self.BoundarySettings.get('VelocityIsCartesian', False) self.form.radioButtonCart.setChecked(cart) self.form.radioButtonMagNormal.setChecked(not cart) self.form.inputCartX.setText( str(self.BoundarySettings.get('Ux')) + "m/s") self.form.inputCartY.setText( str(self.BoundarySettings.get('Uy')) + "m/s") self.form.inputCartZ.setText( str(self.BoundarySettings.get('Uz')) + "m/s") self.form.inputVelocityMag.setText( str(self.BoundarySettings.get('VelocityMag')) + "m/s") self.form.lineDirection.setText( self.BoundarySettings.get('DirectionFace')) self.form.checkReverse.setChecked( bool(self.BoundarySettings.get('ReverseNormal'))) self.form.inputPressure.setText( str(self.BoundarySettings.get('Pressure')) + "kg*m/s^2") self.form.inputSlipRatio.setText( str(self.BoundarySettings.get('SlipRatio'))) self.form.inputVolFlowRate.setText( str(self.BoundarySettings.get('VolFlowRate')) + "m^3/s") self.form.inputMassFlowRate.setText( str(self.BoundarySettings.get('MassFlowRate')) + "kg/s") buttonId = self.BoundarySettings.get('PorousBaffleMethod', 0) selButton = self.form.buttonGroupPorous.button(buttonId) if selButton is not None: selButton.setChecked(True) self.buttonGroupPorousClicked( selButton) # Signal is not generated on setChecked above self.form.inputPressureDropCoeff.setText( str(self.BoundarySettings.get('PressureDropCoeff'))) self.form.inputWireDiameter.setText( str(self.BoundarySettings.get('ScreenWireDiameter')) + "m") self.form.inputSpacing.setText( str(self.BoundarySettings.get('ScreenSpacing')) + "m") if self.turbModel is not None: self.form.comboTurbulenceSpecification.addItems( TURBULENT_INLET_SPEC[self.turbModel][0]) ti = indexOrDefault( TURBULENT_INLET_SPEC[self.turbModel][1], self.BoundarySettingsOrig.get('TurbulenceInletSpecification'), 0) self.form.comboTurbulenceSpecification.setCurrentIndex(ti) self.form.comboThermalBoundaryType.addItems(THERMAL_BOUNDARY_NAMES) thi = indexOrDefault(THERMAL_BOUNDARY_TYPES, self.BoundarySettings.get('ThermalBoundaryType'), 0) self.form.comboThermalBoundaryType.setCurrentIndex(thi) self.form.inputKineticEnergy.setText( str(self.BoundarySettings.get('TurbulentKineticEnergy')) + "m^2/s^2") self.form.inputSpecificDissipationRate.setText( str(self.BoundarySettings.get('SpecificDissipationRate')) + "rad/s") self.form.inputIntensity.setText( str(self.BoundarySettings.get('TurbulenceIntensity'))) self.form.inputLengthScale.setText( str(self.BoundarySettings.get('TurbulenceLengthScale')) + "m") # First time, add any currently selected faces to list if len(self.obj.References) == 0: self.selecting_references = True self.add_selection_to_ref_list() self.selecting_references = False FreeCADGui.Selection.clearSelection() self.update_selectionbuttons_ui()