def __init__(self, analysis_obj): super(CfdCaseWriterFoam, self).__init__() """ analysis_obj should contains all the information needed, boundaryConditionList is a list of all boundary Conditions objects(FemConstraint) """ self.analysis_obj = analysis_obj self.solver_obj = CfdTools.getSolver(analysis_obj) self.physics_model, isPresent = CfdTools.getPhysicsModel(analysis_obj) self.mesh_obj = CfdTools.getMesh(analysis_obj) self.material_objs = CfdTools.getMaterials(analysis_obj) self.bc_group = CfdTools.getCfdBoundaryGroup(analysis_obj) self.initial_conditions, isPresent = CfdTools.getInitialConditions( analysis_obj) self.porousZone_objs, self.porousZonePresent = CfdTools.getPorousObjects( analysis_obj) self.alphaZone_objs = CfdTools.getAlphaObjects(analysis_obj) self.zone_objs = CfdTools.getZoneObjects(analysis_obj) self.mesh_generated = False self.signals = CfdCaseWriterSignals() if len(self.alphaZone_objs) > 0: self.physics_model['Time'] = 'Transient' # TODO: remove this code and add GUI support for transient simulations self.solver_obj.TimeStep = 0.001 self.solver_obj.WriteInterval = 0.05 self.solver_obj.EndTime = 1
def __init__(self, analysis_obj): self.analysis_obj = analysis_obj self.solver_obj = CfdTools.getSolver(analysis_obj) self.physics_model = CfdTools.getPhysicsModel(analysis_obj) self.mesh_obj = CfdTools.getMesh(analysis_obj) self.material_objs = CfdTools.getMaterials(analysis_obj) self.bc_group = CfdTools.getCfdBoundaryGroup(analysis_obj) self.initial_conditions = CfdTools.getInitialConditions(analysis_obj) self.porousZone_objs = CfdTools.getPorousZoneObjects(analysis_obj) self.initialisationZone_objs = CfdTools.getInitialisationZoneObjects(analysis_obj) self.zone_objs = CfdTools.getZoneObjects(analysis_obj) self.mesh_generated = False self.working_dir = CfdTools.getOutputPath(self.analysis_obj)
def __init__(self, analysis_obj): self.analysis_obj = analysis_obj self.solver_obj = CfdTools.getSolver(analysis_obj) self.physics_model, isPresent = CfdTools.getPhysicsModel(analysis_obj) self.mesh_obj = CfdTools.getMesh(analysis_obj) self.material_objs = CfdTools.getMaterials(analysis_obj) self.bc_group = CfdTools.getCfdBoundaryGroup(analysis_obj) self.initial_conditions, isPresent = CfdTools.getInitialConditions(analysis_obj) self.porousZone_objs = CfdTools.getPorousZoneObjects(analysis_obj) self.initialisationZone_objs = CfdTools.getInitialisationZoneObjects(analysis_obj) self.zone_objs = CfdTools.getZoneObjects(analysis_obj) self.conversion2D_obj,self.conversionObjPresent = CfdTools.get2DConversionObject(analysis_obj) self.mesh_generated = False
def setEdit(self, vobj, mode): analysis_object = CfdTools.getParentAnalysisObject(self.Object) if analysis_object is None: CfdTools.cfdError("No parent analysis object found") return False physics_model = CfdTools.getPhysicsModel(analysis_object) if not physics_model: CfdTools.cfdError("Analysis object must have a physics object") return False import _TaskPanelCfdFluidProperties taskd = _TaskPanelCfdFluidProperties.TaskPanelCfdFluidProperties(self.Object, physics_model) taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) return True
def setEdit(self, vobj, mode): analysis_object = CfdTools.getParentAnalysisObject(self.Object) if analysis_object is None: CfdTools.cfdError("No parent analysis object found") return False physics_model, is_present = CfdTools.getPhysicsModel(analysis_object) if not is_present: CfdTools.cfdError("Analysis object must have a physics object") return False boundaries = CfdTools.getCfdBoundaryGroup(analysis_object) import _TaskPanelCfdInitialiseInternalFlowField taskd = _TaskPanelCfdInitialiseInternalFlowField._TaskPanelCfdInitialiseInternalFlowField( self.Object, physics_model, boundaries) taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) return True
def __init__(self, analysis_obj): super(CfdCaseWriterFoam, self).__init__() self.analysis_obj = analysis_obj self.solver_obj = CfdTools.getSolver(analysis_obj) self.physics_model, isPresent = CfdTools.getPhysicsModel(analysis_obj) self.mesh_obj = CfdTools.getMesh(analysis_obj) self.material_objs = CfdTools.getMaterials(analysis_obj) self.bc_group = CfdTools.getCfdBoundaryGroup(analysis_obj) self.initial_conditions, isPresent = CfdTools.getInitialConditions( analysis_obj) self.porousZone_objs = CfdTools.getPorousZoneObjects(analysis_obj) self.initialisationZone_objs = CfdTools.getInitialisationZoneObjects( analysis_obj) self.zone_objs = CfdTools.getZoneObjects(analysis_obj) self.mesh_generated = False self.signals = CfdCaseWriterSignals()
def setEdit(self, vobj, mode): analysis_object = CfdTools.getParentAnalysisObject(self.Object) if analysis_object is None: CfdTools.cfdError("Boundary must have a parent analysis object") return False physics_model, is_present = CfdTools.getPhysicsModel(analysis_object) if not is_present: CfdTools.cfdError("Analysis object must have a physics object") return False import _TaskPanelCfdFluidBoundary taskd = _TaskPanelCfdFluidBoundary.TaskPanelCfdFluidBoundary(self.Object, physics_model) for obj in FreeCAD.ActiveDocument.Objects: if obj.isDerivedFrom("Fem::FemMeshObject"): obj.ViewObject.hide() obj.Part.ViewObject.show() self.Object.ViewObject.show() taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) return True
def createInletBoundary(self): self.inlet_boundary = CfdFluidBoundary.makeCfdFluidBoundary('inlet') bc_set = self.inlet_boundary.BoundarySettings bc_set['BoundaryType'] = 'inlet' bc_set['BoundarySubtype'] = 'uniformVelocity' bc_set['Ux'] = 1 bc_set['Uy'] = 0 bc_set['Uz'] = 0 # Test addSelection and rebuild_list_references doc = FreeCAD.getDocument(self.__class__.__doc_name) obj = doc.getObject('inlet') vobj = obj.ViewObject import _TaskPanelCfdFluidBoundary physics_model, is_present = CfdTools.getPhysicsModel(self.analysis) material_objs = CfdTools.getMaterials(self.analysis) taskd = _TaskPanelCfdFluidBoundary.TaskPanelCfdFluidBoundary(obj, physics_model, material_objs) taskd.obj = vobj.Object taskd.selecting_references = True taskd.addSelection(doc.Name, doc.getObject(self.__class__.__part_name).Name, 'Face1') taskd.accept()
def Activated(self): FreeCAD.Console.PrintMessage("Set fluid properties \n") FreeCAD.ActiveDocument.openTransaction("Set CfdFluidMaterialProperty") FreeCADGui.doCommand("") FreeCADGui.addModule("CfdTools") FreeCADGui.addModule("CfdFluidMaterial") editing_existing = False analysis_object = CfdTools.getActiveAnalysis() if analysis_object is None: CfdTools.cfdError("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)