예제 #1
0
 def store(self):
     FreeCADGui.doCommand(
         "\nFreeCAD.ActiveDocument.{}.CharacteristicLengthMax "
         "= '{}'".format(self.mesh_obj.Name, getQuantity(self.form.if_max)))
     FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.MeshUtility "
                          "= '{}'".format(
                              self.mesh_obj.Name,
                              self.form.cb_utility.currentText()))
     FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.ElementDimension "
                          "= '{}'".format(
                              self.mesh_obj.Name,
                              self.form.cb_dimension.currentText()))
     FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.CellsBetweenLevels "
                          "= {}".format(
                              self.mesh_obj.Name,
                              self.form.if_cellsbetweenlevels.value()))
     FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.EdgeRefinement "
                          "= {}".format(self.mesh_obj.Name,
                                        self.form.if_edgerefine.value()))
     point_in_mesh = {
         'x': getQuantity(self.form.if_pointInMeshX),
         'y': getQuantity(self.form.if_pointInMeshY),
         'z': getQuantity(self.form.if_pointInMeshZ)
     }
     FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.PointInMesh "
                          "= {}".format(self.mesh_obj.Name, point_in_mesh))
예제 #2
0
 def accept(self):
     if self.sel_server:
         FreeCADGui.Selection.removeObserver(self.sel_server)
     FreeCADGui.ActiveDocument.resetEdit()
     FreeCAD.ActiveDocument.recompute()
     # Macro script
     FreeCADGui.doCommand("referenceList = []")
     for ref in self.obj.References:
         FreeCADGui.doCommand("referenceList.append(('{}','{}'))".format(
             ref[0], ref[1]))
     FreeCADGui.doCommand(
         "FreeCAD.ActiveDocument.{}.References = referenceList".format(
             self.obj.Name))
     FreeCADGui.doCommand("\nFreeCAD.ActiveDocument.{}.RelativeLength "
                          "= {}".format(self.obj.Name,
                                        self.form.if_rellen.value()))
     if self.mesh_obj.MeshUtility != 'gmsh':
         FreeCADGui.doCommand(
             "FreeCAD.ActiveDocument.{}.RefinementThickness "
             "= '{}'".format(self.obj.Name,
                             getQuantity(self.form.if_refinethick)))
         if self.form.check_boundlayer.isChecked():
             num_layers = self.form.if_numlayer.value()
         else:
             num_layers = 1
         FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.NumberLayers "
                              "= {}".format(self.obj.Name, num_layers))
         FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.ExpansionRatio "
                              "= {}".format(self.obj.Name,
                                            self.form.if_expratio.value()))
         FreeCADGui.doCommand(
             "FreeCAD.ActiveDocument.{}.FirstLayerHeight "
             "= '{}'".format(self.obj.Name,
                             getQuantity(self.form.if_firstlayerheight)))
         FreeCADGui.doCommand(
             "FreeCAD.ActiveDocument.{}.RegionEdgeRefinement "
             "= {}".format(self.obj.Name,
                           self.form.if_edgerefinement.value()))
         FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.Baffle "
                              "= {}".format(
                                  self.obj.Name,
                                  self.form.baffle_check.isChecked()))
         FreeCADGui.doCommand(
             "FreeCAD.ActiveDocument.{}.Internal "
             "= {}".format(self.obj.Name,
                           self.form.volumeRefinementToggle.isChecked()))
     return True
예제 #3
0
    def accept(self):
        doc = FreeCADGui.getDocument(self.obj.Document)
        doc.resetEdit()

        FreeCADGui.doCommand("\ninit = FreeCAD.ActiveDocument.{}".format(self.obj.Name))
        FreeCADGui.doCommand("init.PotentialFoam = {}".format(self.form.radioButtonPotentialFlow.isChecked()))
        FreeCADGui.doCommand("init.UseInletUPValues = {}".format(self.form.radioButtonUseInletValuesUP.isChecked()))
        FreeCADGui.doCommand("init.Ux = '{}'".format(getQuantity(self.form.Ux)))
        FreeCADGui.doCommand("init.Uy = '{}'".format(getQuantity(self.form.Uy)))
        FreeCADGui.doCommand("init.Uz = '{}'".format(getQuantity(self.form.Uz)))
        FreeCADGui.doCommand("init.Pressure = '{}'".format(getQuantity(self.form.pressure)))
        FreeCADGui.doCommand("init.VolumeFractions = {}".format(self.alphas))
        FreeCADGui.doCommand("init.UseInletTemperatureValues "
                             "= {}".format(self.form.checkUseInletValuesThermal.isChecked()))
        FreeCADGui.doCommand("init.Temperature "
                             "= '{}'".format(getQuantity(self.form.inputTemperature)))
        FreeCADGui.doCommand("init.UseInletTurbulenceValues "
                             "= {}".format(self.form.checkUseInletValues.isChecked()))
        FreeCADGui.doCommand("init.omega = '{}'".format(getQuantity(self.form.inputOmega)))
        FreeCADGui.doCommand("init.k = '{}'".format(getQuantity(self.form.inputk)))
        inlet = self.form.comboInlets.currentData()
        if inlet:
            FreeCADGui.doCommand("init.Inlet = FreeCAD.ActiveDocument.{}".format(inlet))
        else:
            FreeCADGui.doCommand("init.Inlet = None")
예제 #4
0
 def manualEdit(self):
     if not self.selecting_predefined:
         self.form.PredefinedMaterialLibraryComboBox.setCurrentIndex(
             self.form.PredefinedMaterialLibraryComboBox.findText('Custom'))
         self.material = {
             'Name': 'Custom',
             'Description': 'User-entered properties'
         }
         for f in self.fields:
             self.material[f] = getQuantity(self.text_boxes[f])
         self.selectPredefine()
예제 #5
0
 def inputVolumeFractionChanged(self):
     self.alphas[self.form.comboFluid.currentText()] = getQuantity(self.form.inputVolumeFraction)
예제 #6
0
    def accept(self):
        if self.obj.Label.startswith("CfdFluidBoundary"):
            self.obj.Label = self.obj.BoundaryType
        FreeCADGui.Selection.removeObserver(self)

        doc = FreeCADGui.getDocument(self.obj.Document)
        doc.resetEdit()

        FreeCADGui.doCommand("\nbc = FreeCAD.ActiveDocument.{}".format(
            self.obj.Name))
        # Type
        FreeCADGui.doCommand("bc.BoundaryType "
                             "= '{}'".format(self.obj.BoundaryType))
        FreeCADGui.doCommand("bc.BoundarySubType "
                             "= '{}'".format(self.obj.BoundarySubType))
        FreeCADGui.doCommand(
            "bc.ThermalBoundaryType "
            "= '{}'".format(CfdFluidBoundary.THERMAL_BOUNDARY_TYPES[
                self.form.comboThermalBoundaryType.currentIndex()]))
        # Velocity
        FreeCADGui.doCommand("bc.VelocityIsCartesian "
                             "= {}".format(
                                 self.form.radioButtonCart.isChecked()))
        FreeCADGui.doCommand("bc.Ux "
                             "= '{}'".format(getQuantity(
                                 self.form.inputCartX)))
        FreeCADGui.doCommand("bc.Uy "
                             "= '{}'".format(getQuantity(
                                 self.form.inputCartY)))
        FreeCADGui.doCommand("bc.Uz "
                             "= '{}'".format(getQuantity(
                                 self.form.inputCartZ)))
        FreeCADGui.doCommand("bc.VelocityMag "
                             "= '{}'".format(
                                 getQuantity(self.form.inputVelocityMag)))
        FreeCADGui.doCommand("bc.DirectionFace "
                             "= '{}'".format(self.form.lineDirection.text()))
        FreeCADGui.doCommand("bc.ReverseNormal "
                             "= {}".format(self.form.checkReverse.isChecked()))
        FreeCADGui.doCommand("bc.MassFlowRate "
                             "= '{}'".format(
                                 getQuantity(self.form.inputMassFlowRate)))
        FreeCADGui.doCommand("bc.VolFlowRate "
                             "= '{}'".format(
                                 getQuantity(self.form.inputVolFlowRate)))
        # Presure
        FreeCADGui.doCommand("bc.Pressure "
                             "= '{}'".format(
                                 getQuantity(self.form.inputPressure)))
        # Wall
        FreeCADGui.doCommand("bc.SlipRatio "
                             "= '{}'".format(
                                 getQuantity(self.form.inputSlipRatio)))
        # Thermal
        FreeCADGui.doCommand("bc.Temperature "
                             "= '{}'".format(
                                 getQuantity(self.form.inputTemperature)))
        FreeCADGui.doCommand("bc.HeatFlux "
                             "= '{}'".format(
                                 getQuantity(self.form.inputHeatFlux)))
        FreeCADGui.doCommand(
            "bc.HeatTransferCoeff "
            "= '{}'".format(getQuantity(self.form.inputHeatTransferCoeff)))

        # Turbulence
        if self.turbModel in CfdFluidBoundary.TURBULENT_INLET_SPEC:
            turb_index = self.form.comboTurbulenceSpecification.currentIndex()
            FreeCADGui.doCommand("bc.TurbulenceInletSpecification "
                                 "= '{}'".format(
                                     CfdFluidBoundary.TURBULENT_INLET_SPEC[
                                         self.turbModel][1][turb_index]))
        else:
            FreeCADGui.doCommand("bc.TurbulenceInletSpecification "
                                 "= '{}'".format(
                                     self.obj.TurbulenceInletSpecification))
        FreeCADGui.doCommand("bc.TurbulentKineticEnergy "
                             "= '{}'".format(
                                 getQuantity(self.form.inputKineticEnergy)))
        FreeCADGui.doCommand("bc.SpecificDissipationRate "
                             "= '{}'".format(
                                 getQuantity(
                                     self.form.inputSpecificDissipationRate)))
        FreeCADGui.doCommand("bc.TurbulenceIntensity "
                             "= '{}'".format(
                                 getQuantity(self.form.inputIntensity)))
        FreeCADGui.doCommand("bc.TurbulenceLengthScale "
                             "= '{}'".format(
                                 getQuantity(self.form.inputLengthScale)))
        FreeCADGui.doCommand("bc.VolumeFractions = {}".format(self.alphas))

        # Porous
        FreeCADGui.doCommand("bc.PorousBaffleMethod "
                             "= '{}'".format(CfdFluidBoundary.POROUS_METHODS[
                                 self.form.buttonGroupPorous.checkedId()]))
        FreeCADGui.doCommand(
            "bc.PressureDropCoeff "
            "= '{}'".format(getQuantity(self.form.inputPressureDropCoeff)))
        FreeCADGui.doCommand("bc.ScreenWireDiameter "
                             "= '{}'".format(
                                 getQuantity(self.form.inputWireDiameter)))
        FreeCADGui.doCommand("bc.ScreenSpacing "
                             "= '{}'".format(
                                 getQuantity(self.form.inputSpacing)))
        FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.Label = '{}'".format(
            self.obj.Name, self.obj.Label))
        faces = []
        for ref in self.obj.References:
            faces.append(ref)
        self.obj.References = []
        FreeCADGui.doCommand(
            "FreeCAD.ActiveDocument.{}.References = []".format(self.obj.Name))
        for f in faces:
            FreeCADGui.doCommand(
                "FreeCAD.ActiveDocument.{}.References.append({})".format(
                    self.obj.Name, f))
        FreeCADGui.doCommand("FreeCAD.ActiveDocument.recompute()")
        self.faceSelector.closing()
    def accept(self):
        if self.obj.Name.startswith('PorousZone'):
            FreeCADGui.doCommand("p = FreeCAD.ActiveDocument.{}".format(
                self.obj.Name))
            FreeCADGui.doCommand("p.PorousCorrelation = '{}'".format(
                CfdZone.POROUS_CORRELATIONS[
                    self.form.comboBoxCorrelation.currentIndex()]))
            FreeCADGui.doCommand("p.D1 = '{}'".format(getQuantity(
                self.form.dx)))
            FreeCADGui.doCommand("p.D2 = '{}'".format(getQuantity(
                self.form.dy)))
            FreeCADGui.doCommand("p.D3 = '{}'".format(getQuantity(
                self.form.dz)))
            FreeCADGui.doCommand("p.F1 = '{}'".format(getQuantity(
                self.form.fx)))
            FreeCADGui.doCommand("p.F2 = '{}'".format(getQuantity(
                self.form.fy)))
            FreeCADGui.doCommand("p.F3 = '{}'".format(getQuantity(
                self.form.fz)))
            FreeCADGui.doCommand("p.e1 = ({}, {}, {})".format(
                self.form.e1x.property('quantity').getValueAs("1").Value,
                self.form.e1y.property('quantity').getValueAs("1").Value,
                self.form.e1z.property('quantity').getValueAs("1").Value))
            FreeCADGui.doCommand("p.e2 = ({}, {}, {})".format(
                self.form.e2x.property('quantity').getValueAs("1").Value,
                self.form.e2y.property('quantity').getValueAs("1").Value,
                self.form.e2z.property('quantity').getValueAs("1").Value))
            FreeCADGui.doCommand("p.e3 = ({}, {}, {})".format(
                self.form.e3x.property('quantity').getValueAs("1").Value,
                self.form.e3y.property('quantity').getValueAs("1").Value,
                self.form.e3z.property('quantity').getValueAs("1").Value))
            FreeCADGui.doCommand("p.OuterDiameter = '{}'".format(
                getQuantity(self.form.inputOuterDiameter)))
            FreeCADGui.doCommand("p.TubeAxis = ({}, {}, {} )".format(
                self.form.inputTubeAxisX.property('quantity').getValueAs(
                    "1").Value,
                self.form.inputTubeAxisY.property('quantity').getValueAs(
                    "1").Value,
                self.form.inputTubeAxisZ.property('quantity').getValueAs(
                    "1").Value))
            FreeCADGui.doCommand("p.TubeSpacing = '{}'".format(
                getQuantity(self.form.inputTubeSpacing)))
            FreeCADGui.doCommand("p.SpacingDirection = ({}, {}, {})".format(
                self.form.inputBundleLayerNormalX.property(
                    'quantity').getValueAs("1").Value,
                self.form.inputBundleLayerNormalY.property(
                    'quantity').getValueAs("1").Value,
                self.form.inputBundleLayerNormalZ.property(
                    'quantity').getValueAs("1").Value))
            FreeCADGui.doCommand("p.AspectRatio = '{}'".format(
                getQuantity(self.form.inputAspectRatio)))
            FreeCADGui.doCommand("p.VelocityEstimate = '{}'".format(
                getQuantity(self.form.inputVelocityEstimate)))

        elif self.obj.Name.startswith('InitialisationZone'):
            FreeCADGui.doCommand("p = FreeCAD.ActiveDocument.{}".format(
                self.obj.Name))
            FreeCADGui.doCommand("p.VelocitySpecified = {}".format(
                self.form.checkVelocity.isChecked()))
            FreeCADGui.doCommand("p.Ux = '{}'".format(
                getQuantity(self.form.inputUx)))
            FreeCADGui.doCommand("p.Uy = '{}'".format(
                getQuantity(self.form.inputUy)))
            FreeCADGui.doCommand("p.Uz = '{}'".format(
                getQuantity(self.form.inputUz)))
            FreeCADGui.doCommand("p.PressureSpecified = {}".format(
                self.form.checkPressure.isChecked()))
            FreeCADGui.doCommand("p.Pressure = '{}'".format(
                getQuantity(self.form.inputPressure)))
            FreeCADGui.doCommand("p.VolumeFractionSpecified = {}".format(
                self.form.checkAlpha.isChecked()))
            FreeCADGui.doCommand("p.VolumeFractions = {}".format(self.alphas))

        FreeCADGui.doCommand(
            "FreeCAD.ActiveDocument.{}.References = {}".format(
                self.obj.Name, self.obj.References))

        doc = FreeCADGui.getDocument(self.obj.Document)
        doc.resetEdit()
 def inputVolumeFractionChanged(self, text):
     alphaName = self.form.comboFluid.currentText()
     self.alphas[alphaName] = getQuantity(self.form.inputVolumeFraction)
    def accept(self):
        doc = FreeCADGui.getDocument(self.obj.Document)
        doc.resetEdit()

        FreeCADGui.doCommand("\ninit = FreeCAD.ActiveDocument.{}".format(
            self.obj.Name))
        FreeCADGui.doCommand("init.PotentialFlow = {}".format(
            self.form.radioButtonPotentialFlowU.isChecked()))
        FreeCADGui.doCommand("init.UseInletUValues = {}".format(
            self.form.radioButtonUseInletValuesU.isChecked()))
        FreeCADGui.doCommand("init.Ux = '{}'".format(getQuantity(
            self.form.Ux)))
        FreeCADGui.doCommand("init.Uy = '{}'".format(getQuantity(
            self.form.Uy)))
        FreeCADGui.doCommand("init.Uz = '{}'".format(getQuantity(
            self.form.Uz)))
        FreeCADGui.doCommand("init.UseOutletPValue = {}".format(
            self.form.radioButtonUseInletValuesP.isChecked()))
        FreeCADGui.doCommand("init.PotentialFlowP = {}".format(
            self.form.radioButtonPotentialFlowP.isChecked()))
        FreeCADGui.doCommand("init.Pressure = '{}'".format(
            getQuantity(self.form.pressure)))
        FreeCADGui.doCommand("init.VolumeFractions = {}".format(self.alphas))
        FreeCADGui.doCommand(
            "init.UseInletTemperatureValue "
            "= {}".format(self.form.checkUseInletValuesThermal.isChecked()))
        FreeCADGui.doCommand("init.Temperature "
                             "= '{}'".format(
                                 getQuantity(self.form.inputTemperature)))
        FreeCADGui.doCommand(
            "init.UseInletTurbulenceValues "
            "= {}".format(self.form.checkUseInletValuesTurb.isChecked()))
        FreeCADGui.doCommand("init.omega = '{}'".format(
            getQuantity(self.form.inputOmega)))
        FreeCADGui.doCommand("init.k = '{}'".format(
            getQuantity(self.form.inputk)))
        boundaryU = self.form.comboBoundaryU.currentData()
        boundaryP = self.form.comboBoundaryP.currentData()
        boundaryT = self.form.comboBoundaryT.currentData()
        boundaryTurb = self.form.comboBoundaryTurb.currentData()
        if boundaryU:
            FreeCADGui.doCommand(
                "init.BoundaryU = FreeCAD.ActiveDocument.{}".format(boundaryU))
        else:
            FreeCADGui.doCommand("init.BoundaryU = None")
        if boundaryP:
            FreeCADGui.doCommand(
                "init.BoundaryP = FreeCAD.ActiveDocument.{}".format(boundaryP))
        else:
            FreeCADGui.doCommand("init.BoundaryP = None")
        if boundaryT:
            FreeCADGui.doCommand(
                "init.BoundaryT = FreeCAD.ActiveDocument.{}".format(boundaryT))
        else:
            FreeCADGui.doCommand("init.BoundaryT = None")
        if boundaryTurb:
            FreeCADGui.doCommand(
                "init.BoundaryTurb = FreeCAD.ActiveDocument.{}".format(
                    boundaryTurb))
        else:
            FreeCADGui.doCommand("init.BoundaryTurb = None")