예제 #1
0
    def setEdit(self, vobj, mode):
        analysis_object = CfdTools.getParentAnalysisObject(self.Object)
        if analysis_object is None:
            CfdTools.cfdErrorBox(
                "Scalar transport object must have a parent analysis object")
            return False

        from CfdOF.Solve import TaskPanelCfdScalarTransportFunctions
        import importlib
        importlib.reload(TaskPanelCfdScalarTransportFunctions)
        taskd = TaskPanelCfdScalarTransportFunctions.TaskPanelCfdScalarTransportFunctions(
            self.Object)
        taskd.obj = vobj.Object
        FreeCADGui.Control.showDialog(taskd)
        return True
예제 #2
0
 def setEdit(self, vobj, mode):
     analysis_object = CfdTools.getParentAnalysisObject(self.Object)
     if analysis_object is None:
         CfdTools.cfdErrorBox("No parent analysis object found")
         return False
     physics_model = CfdTools.getPhysicsModel(analysis_object)
     if not physics_model:
         CfdTools.cfdErrorBox("Analysis object must have a physics object")
         return False
     import importlib
     importlib.reload(TaskPanelCfdFluidProperties)
     self.taskd = TaskPanelCfdFluidProperties.TaskPanelCfdFluidProperties(self.Object, physics_model)
     self.taskd.obj = vobj.Object
     FreeCADGui.Control.showDialog(self.taskd)
     return True
예제 #3
0
    def setEdit(self, vobj, mode):
        analysis_object = CfdTools.getParentAnalysisObject(self.Object)
        if analysis_object is None:
            CfdTools.cfdErrorBox(
                "Reporting function must have a parent analysis object")
            return False

        from CfdOF.PostProcess import TaskPanelCfdReportingFunction
        import importlib
        importlib.reload(TaskPanelCfdReportingFunction)
        taskd = TaskPanelCfdReportingFunction.TaskPanelCfdReportingFunction(
            self.Object)
        self.Object.ViewObject.show()
        taskd.obj = vobj.Object
        FreeCADGui.Control.showDialog(taskd)
        return True
예제 #4
0
    def setEdit(self, vobj, mode):
        analysis_object = CfdTools.getParentAnalysisObject(self.Object)
        if analysis_object is None:
            CfdTools.cfdErrorBox("No parent analysis object found")
            return False
        physics_model = CfdTools.getPhysicsModel(analysis_object)
        if not physics_model:
            CfdTools.cfdErrorBox("Analysis object must have a physics object")
            return False
        boundaries = CfdTools.getCfdBoundaryGroup(analysis_object)
        material_objs = CfdTools.getMaterials(analysis_object)

        import importlib
        importlib.reload(TaskPanelCfdInitialiseInternalFlowField)
        self.taskd = TaskPanelCfdInitialiseInternalFlowField.TaskPanelCfdInitialiseInternalFlowField(
            self.Object, physics_model, boundaries, material_objs)
        self.taskd.obj = vobj.Object
        FreeCADGui.Control.showDialog(self.taskd)
        return True
예제 #5
0
    def setEdit(self, vobj, mode):
        analysis_object = CfdTools.getParentAnalysisObject(self.Object)
        if analysis_object is None:
            CfdTools.cfdErrorBox("Boundary must have a parent analysis object")
            return False
        physics_model = CfdTools.getPhysicsModel(analysis_object)
        if not physics_model:
            CfdTools.cfdErrorBox("Analysis object must have a physics object")
            return False
        material_objs = CfdTools.getMaterials(analysis_object)

        from CfdOF.Solve import TaskPanelCfdFluidBoundary
        import importlib
        importlib.reload(TaskPanelCfdFluidBoundary)
        self.taskd = TaskPanelCfdFluidBoundary.TaskPanelCfdFluidBoundary(
            self.Object, physics_model, material_objs)
        self.Object.ViewObject.show()
        self.taskd.obj = vobj.Object
        FreeCADGui.Control.showDialog(self.taskd)
        return True
예제 #6
0
 def Activated(self):
     FreeCAD.Console.PrintMessage("Set fluid properties \n")
     FreeCAD.ActiveDocument.openTransaction("Set CfdFluidMaterialProperty")
     FreeCADGui.doCommand("from CfdOF import CfdTools")
     FreeCADGui.doCommand("from CfdOF.Solve import CfdFluidMaterial")
     editing_existing = False
     analysis_object = CfdTools.getActiveAnalysis()
     if analysis_object is None:
         CfdTools.cfdErrorBox("No active analysis object found")
         return False
     physics_model = CfdTools.getPhysicsModel(analysis_object)
     if not physics_model or physics_model.Phase == 'Single':
         members = analysis_object.Group
         for i in members:
             if isinstance(i.Proxy, CfdMaterial):
                 FreeCADGui.activeDocument().setEdit(i.Name)
                 editing_existing = True
     if not editing_existing:
         FreeCADGui.doCommand(
             "CfdTools.getActiveAnalysis().addObject(CfdFluidMaterial.makeCfdFluidMaterial('FluidProperties'))")
         FreeCADGui.ActiveDocument.setEdit(FreeCAD.ActiveDocument.ActiveObject.Name)
예제 #7
0
    def automaticInsidePointDetect(self):
        # Snappy requires that the chosen internal point must remain internal during the meshing process and therefore
        # the meshing algorithm might fail if the point accidentally falls in a sliver between the mesh and the geometry
        # As a safety measure, the check distance is chosen to be approximately the size of the background mesh.
        shape = self.part_obj.Shape
        step_size = self.clmax * 2.5

        bound_box = self.part_obj.Shape.BoundBox
        error_safety_factor = 2.0

        if (step_size * error_safety_factor >= bound_box.XLength
                or step_size * error_safety_factor >= bound_box.YLength
                or step_size * error_safety_factor >= bound_box.ZLength):
            CfdTools.cfdErrorBox(
                "Current choice in characteristic length of {} might be too large for automatic "
                "internal point detection.".format(self.clmax))
        x1 = bound_box.XMin
        x2 = bound_box.XMax
        y1 = bound_box.YMin
        y2 = bound_box.YMax
        z1 = bound_box.ZMin
        z2 = bound_box.ZMax

        import random
        if not shape.isClosed():
            CfdTools.cfdErrorBox(
                "Can not find an internal point as shape is not closed - please specify manually."
            )
            return None

        for i in range(100):
            x = random.uniform(x1, x2)
            y = random.uniform(y1, y2)
            z = random.uniform(z1, z2)
            pointCheck = FreeCAD.Vector(x, y, z)
            result = shape.isInside(pointCheck, step_size, False)
            if result:
                return pointCheck

        CfdTools.cfdErrorBox(
            "Failed to find an internal point - please specify manually.")
        return None