Ejemplo n.º 1
0
 def __init__(self, obj):
     self._obj = obj
     self._refWidget = FemSelectionWidgets.SolidSelector()
     self._refWidget.setReferences(obj.References)
     propWidget = obj.ViewObject.Proxy.getTaskWidget(obj.ViewObject)
     if propWidget is None:
         self.form = self._refWidget
     else:
         self.form = [self.refWidget, propWidget]
     analysis = FemUtils.findAnalysisOfMember(obj)
     self._mesh = FemUtils.getSingleMember(analysis, "Fem::FemMeshObject")
     self._part = self._mesh.Part if self._mesh is not None else None
     self._partVisible = None
     self._meshVisible = None
Ejemplo n.º 2
0
    def __init__(self, obj):

        self.obj = obj
        analysis_obj = CfdTools.getParentAnalysisObject(obj)
        solver_obj = CfdTools.getSolver(analysis_obj)
        material_objs = CfdTools.getMaterials(analysis_obj)

        self.boundaryWidget = CfdBoundaryWidget(obj, None, solver_obj,
                                                material_objs)
        # fill the table in each variable tab, saved from the previous setup, existing case if BC name, done in each widget

        # geometry selection widget, only face is needed as boundary for CFD
        # GeometryElementsSelection(ref, eltypes=[], multigeom=True)  # allow_multiple_geom_types = multigeom
        self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection(
            obj.References, ['Face'], False)
        # check references, has to be after initialization of selectionWidget
        try:
            self.selectionWidget.has_equal_references_shape_types(
            )  # boundarySelector has no such method
        except:
            print(
                '`selectionWidget.has_equal_references_shape_types()` is only available in FreeCAD 0.18+'
            )

        #the magic to have two widgets in one taskpanel
        self.form = [self.selectionWidget, self.boundaryWidget]
        if True:  # todo: check if solver is 'OpenFOAM'
            from CfdFoamTools import getVariableList
            solverSettings = CfdTools.getSolverSettings(
                solver_obj)  # physical_model
            variable_list = getVariableList(solverSettings)

            # TODO: if boundary_settings is empty dict, default setting for each variable could be provided
            if "FoamBoundarySettings" in self.obj.PropertiesList and self.obj.FoamBoundarySettings:
                self.foam_boundary_conditions = self.obj.FoamBoundarySettings
            else:
                print("debug print: variable_list", variable_list)
                self.foam_boundary_conditions = {
                    var: {}
                    for var in variable_list
                }  # {varible: bc_dict, ...}

            from FoamCaseBuilder.FoamBoundaryWidget import FoamBoundaryWidget
            s = {"variables": self.foam_boundary_conditions}
            self.foamWidget = FoamBoundaryWidget(s)
            self.form.append(self.foamWidget)
    def __init__(self, obj):

        self.obj = obj
        analysis_obj = CfdTools.getParentAnalysisObject(obj)
        solver_obj = CfdTools.getSolver(analysis_obj)
        material_objs = CfdTools.getMaterials(analysis_obj)

        from CfdBoundaryWidget import CfdBoundaryWidget
        self.boundaryWidget = CfdBoundaryWidget(obj, None, solver_obj, material_objs)
        # fill the table in each variable tab, saved from the previous setup, existing case if BC name, done in each widget

        # geometry selection widget, only face is needed as boundary
        self.selectionWidget = FemSelectionWidgets.BoundarySelector()
        self.selectionWidget.setReferences(obj.References)
        # check references, has to be after initialisation of selectionWidget
        try:
            self.selectionWidget.has_equal_references_shape_types()
        except:
            RuntimeError('this function only works for FreeCAD 0.18')

        #the magic to have two widgets in one taskpanel
        self.form = [self.selectionWidget, self.boundaryWidget]
        if True:  # todo: check if solver is 'OpenFOAM'
            from CfdFoamTools import getVariableList
            solverSettings = CfdTools.getSolverSettings(solver_obj)  # physical_model
            variable_list = getVariableList(solverSettings)

            # build a parameterTabWidget, with each tab has a tableView
            # TODO: if boundary_settings is empty dict, default setting for each variable could be provided
            if not self.obj.FoamBoundarySettings:
                self.foam_boundary_conditions = {'U': {"key": "value"}, 'p':{"key": "value"}}  # {varible: bc_dict, ...}
            else:
                self.foam_boundary_conditions = self.obj.FoamBoundarySettings
            from FoamCaseBuilder.FoamBoundaryWidget import FoamBoundaryWidget
            self.foamWidget = FoamBoundaryWidget(self.foam_boundary_conditions)
            self.form.append(self.foamWidget)