当前位置: 首页>>代码示例>>Python>>正文


Python ObjectsFem.makeMeshResult方法代码示例

本文整理汇总了Python中ObjectsFem.makeMeshResult方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectsFem.makeMeshResult方法的具体用法?Python ObjectsFem.makeMeshResult怎么用?Python ObjectsFem.makeMeshResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectsFem的用法示例。


在下文中一共展示了ObjectsFem.makeMeshResult方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_z88_disp

# 需要导入模块: import ObjectsFem [as 别名]
# 或者: from ObjectsFem import makeMeshResult [as 别名]
def import_z88_disp(
    filename,
    analysis=None,
    result_name_prefix=None
):
    '''insert a FreeCAD FEM mechanical result object in the ActiveDocument
    pure usage:
    import feminout.importZ88O2Results as importZ88O2Results
    disp_file = '/pathtofile/z88o2.txt'
    importZ88O2Results.import_z88_disp(disp_file)

    the z888i1.txt FEMMesh file needs to be in the same directory as z88o2.txt
    # ahh, make a new document first ;-)
    '''
    from . import importZ88Mesh
    from . import importToolsFem
    import ObjectsFem
    if result_name_prefix is None:
        result_name_prefix = ''
    disp_read = read_z88_disp(filename)
    result_mesh_object = None
    if len(disp_read['Nodes']) > 0:
        if analysis:
            analysis_object = analysis

        # read result mesh
        if filename.endswith('z88o2.txt'):
            mesh_file = filename.replace('o2', 'i1')
            mesh_data = importZ88Mesh.read_z88_mesh(mesh_file)
            femmesh = importToolsFem.make_femmesh(mesh_data)
            result_mesh_object = ObjectsFem.makeMeshResult(
                FreeCAD.ActiveDocument,
                'Result_mesh'
            )
            result_mesh_object.FemMesh = femmesh
        else:
            FreeCAD.Console.PrintError('Z88 mesh file z88i1.txt not found!')

        # create result obj
        for result_set in disp_read['Results']:
            results_name = result_name_prefix + 'results'

            res_obj = ObjectsFem.makeResultMechanical(FreeCAD.ActiveDocument, results_name)
            res_obj.Mesh = result_mesh_object
            res_obj = importToolsFem.fill_femresult_mechanical(res_obj, result_set)
            if analysis:
                analysis_object.addObject(res_obj)

        if FreeCAD.GuiUp:
            if analysis:
                import FemGui
                FemGui.setActiveAnalysis(analysis_object)
            FreeCAD.ActiveDocument.recompute()

    else:
        FreeCAD.Console.PrintError(
            'Problem on Z88 result file import. No nodes found in Z88 result file.\n'
        )
    return res_obj
开发者ID:ianrrees,项目名称:FreeCAD_tinkering,代码行数:61,代码来源:importZ88O2Results.py

示例2: test_femobjects_make

# 需要导入模块: import ObjectsFem [as 别名]
# 或者: from ObjectsFem import makeMeshResult [as 别名]
    def test_femobjects_make(self):
        doc = self.active_doc
        analysis = ObjectsFem.makeAnalysis(doc)

        analysis.addObject(ObjectsFem.makeConstraintBearing(doc))
        analysis.addObject(ObjectsFem.makeConstraintBodyHeatSource(doc))
        analysis.addObject(ObjectsFem.makeConstraintContact(doc))
        analysis.addObject(ObjectsFem.makeConstraintDisplacement(doc))
        analysis.addObject(ObjectsFem.makeConstraintElectrostaticPotential(doc))
        analysis.addObject(ObjectsFem.makeConstraintFixed(doc))
        analysis.addObject(ObjectsFem.makeConstraintFlowVelocity(doc))
        analysis.addObject(ObjectsFem.makeConstraintFluidBoundary(doc))
        analysis.addObject(ObjectsFem.makeConstraintForce(doc))
        analysis.addObject(ObjectsFem.makeConstraintGear(doc))
        analysis.addObject(ObjectsFem.makeConstraintHeatflux(doc))
        analysis.addObject(ObjectsFem.makeConstraintInitialFlowVelocity(doc))
        analysis.addObject(ObjectsFem.makeConstraintInitialTemperature(doc))
        analysis.addObject(ObjectsFem.makeConstraintPlaneRotation(doc))
        analysis.addObject(ObjectsFem.makeConstraintPressure(doc))
        analysis.addObject(ObjectsFem.makeConstraintPulley(doc))
        analysis.addObject(ObjectsFem.makeConstraintSelfWeight(doc))
        analysis.addObject(ObjectsFem.makeConstraintTemperature(doc))
        analysis.addObject(ObjectsFem.makeConstraintTransform(doc))

        analysis.addObject(ObjectsFem.makeElementFluid1D(doc))
        analysis.addObject(ObjectsFem.makeElementGeometry1D(doc))
        analysis.addObject(ObjectsFem.makeElementGeometry2D(doc))
        analysis.addObject(ObjectsFem.makeElementRotation1D(doc))

        analysis.addObject(ObjectsFem.makeMaterialFluid(doc))
        mat = analysis.addObject(ObjectsFem.makeMaterialSolid(doc))[0]
        analysis.addObject(ObjectsFem.makeMaterialMechanicalNonlinear(doc, mat))

        msh = analysis.addObject(ObjectsFem.makeMeshGmsh(doc))[0]
        analysis.addObject(ObjectsFem.makeMeshBoundaryLayer(doc, msh))
        analysis.addObject(ObjectsFem.makeMeshGroup(doc, msh))
        analysis.addObject(ObjectsFem.makeMeshRegion(doc, msh))
        analysis.addObject(ObjectsFem.makeMeshNetgen(doc))
        analysis.addObject(ObjectsFem.makeMeshResult(doc))

        analysis.addObject(ObjectsFem.makeResultMechanical(doc))

        analysis.addObject(ObjectsFem.makeSolverCalculixCcxTools(doc))
        analysis.addObject(ObjectsFem.makeSolverCalculix(doc))
        sol = analysis.addObject(ObjectsFem.makeSolverElmer(doc))[0]
        analysis.addObject(ObjectsFem.makeSolverZ88(doc))

        analysis.addObject(ObjectsFem.makeEquationElasticity(doc, sol))
        analysis.addObject(ObjectsFem.makeEquationElectrostatic(doc, sol))
        analysis.addObject(ObjectsFem.makeEquationFlow(doc, sol))
        analysis.addObject(ObjectsFem.makeEquationFluxsolver(doc, sol))
        analysis.addObject(ObjectsFem.makeEquationHeat(doc, sol))
        # is = 43 (just copy in empty file to test, or run unit test case, it is printed)
        # TODO if the equations and gmsh mesh childs are added to the analysis,
        # they show up twice on Tree (on solver resp. gemsh mesh obj and on analysis)
        # https://forum.freecadweb.org/viewtopic.php?t=25283

        doc.recompute()
        self.assertEqual(len(analysis.Group), testtools.get_defmake_count() - 1)  # because of the analysis itself count -1
开发者ID:DevJohan,项目名称:FreeCAD_sf_master,代码行数:61,代码来源:testcommon.py

示例3: importFrd

# 需要导入模块: import ObjectsFem [as 别名]
# 或者: from ObjectsFem import makeMeshResult [as 别名]
def importFrd(filename, analysis=None, result_name_prefix=None):
    from . import importToolsFem
    import ObjectsFem
    if result_name_prefix is None:
        result_name_prefix = ''
    m = readResult(filename)
    result_mesh_object = None
    if len(m['Nodes']) > 0:
        if analysis:
            analysis_object = analysis

        mesh = importToolsFem.make_femmesh(m)
        result_mesh_object = ObjectsFem.makeMeshResult(FreeCAD.ActiveDocument, 'Result_mesh')
        result_mesh_object.FemMesh = mesh

        positions = []
        for k, v in m['Nodes'].items():
            positions.append(v)
        p_x_max, p_y_max, p_z_max = map(max, zip(*positions))
        p_x_min, p_y_min, p_z_min = map(min, zip(*positions))
        x_span = abs(p_x_max - p_x_min)
        y_span = abs(p_y_max - p_y_min)
        z_span = abs(p_z_max - p_z_min)
        span = max(x_span, y_span, z_span)

        number_of_increments = len(m['Results'])
        for result_set in m['Results']:
            if 'number' in result_set:
                eigenmode_number = result_set['number']
            else:
                eigenmode_number = 0
            step_time = result_set['time']
            step_time = round(step_time, 2)
            if eigenmode_number > 0:
                results_name = result_name_prefix + 'mode_' + str(eigenmode_number) + '_results'
            elif number_of_increments > 1:
                results_name = result_name_prefix + 'time_' + str(step_time) + '_results'
            else:
                results_name = result_name_prefix + 'results'

            results = ObjectsFem.makeResultMechanical(FreeCAD.ActiveDocument, results_name)
            results.Mesh = result_mesh_object
            results = importToolsFem.fill_femresult_mechanical(results, result_set, span)
            if analysis:
                analysis_object.addObject(results)

        if FreeCAD.GuiUp:
            if analysis:
                import FemGui
                FemGui.setActiveAnalysis(analysis_object)
            FreeCAD.ActiveDocument.recompute()

    else:
        FreeCAD.Console.PrintError('Problem on frd file import. No nodes found in frd file.\n')
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:56,代码来源:importCcxFrdResults.py

示例4: test_femobjects_derivedfromstd

# 需要导入模块: import ObjectsFem [as 别名]
# 或者: from ObjectsFem import makeMeshResult [as 别名]
    def test_femobjects_derivedfromstd(self):
        # only the last True type is used
        doc = self.active_doc

        self.assertTrue(ObjectsFem.makeAnalysis(doc).isDerivedFrom('Fem::FemAnalysis'))
        self.assertTrue(ObjectsFem.makeConstraintBearing(doc).isDerivedFrom('Fem::ConstraintBearing'))
        self.assertTrue(ObjectsFem.makeConstraintBodyHeatSource(doc).isDerivedFrom('Fem::ConstraintPython'))
        self.assertTrue(ObjectsFem.makeConstraintContact(doc).isDerivedFrom('Fem::ConstraintContact'))
        self.assertTrue(ObjectsFem.makeConstraintDisplacement(doc).isDerivedFrom('Fem::ConstraintDisplacement'))
        self.assertTrue(ObjectsFem.makeConstraintElectrostaticPotential(doc).isDerivedFrom('Fem::ConstraintPython'))
        self.assertTrue(ObjectsFem.makeConstraintFixed(doc).isDerivedFrom('Fem::ConstraintFixed'))
        self.assertTrue(ObjectsFem.makeConstraintFlowVelocity(doc).isDerivedFrom('Fem::ConstraintPython'))
        self.assertTrue(ObjectsFem.makeConstraintFluidBoundary(doc).isDerivedFrom('Fem::ConstraintFluidBoundary'))
        self.assertTrue(ObjectsFem.makeConstraintForce(doc).isDerivedFrom('Fem::ConstraintForce'))
        self.assertTrue(ObjectsFem.makeConstraintGear(doc).isDerivedFrom('Fem::ConstraintGear'))
        self.assertTrue(ObjectsFem.makeConstraintHeatflux(doc).isDerivedFrom('Fem::ConstraintHeatflux'))
        self.assertTrue(ObjectsFem.makeConstraintInitialFlowVelocity(doc).isDerivedFrom('Fem::ConstraintPython'))
        self.assertTrue(ObjectsFem.makeConstraintInitialTemperature(doc).isDerivedFrom('Fem::ConstraintInitialTemperature'))
        self.assertTrue(ObjectsFem.makeConstraintPlaneRotation(doc).isDerivedFrom('Fem::ConstraintPlaneRotation'))
        self.assertTrue(ObjectsFem.makeConstraintPressure(doc).isDerivedFrom('Fem::ConstraintPressure'))
        self.assertTrue(ObjectsFem.makeConstraintPulley(doc).isDerivedFrom('Fem::ConstraintPulley'))
        self.assertTrue(ObjectsFem.makeConstraintSelfWeight(doc).isDerivedFrom('Fem::ConstraintPython'))
        self.assertTrue(ObjectsFem.makeConstraintTemperature(doc).isDerivedFrom('Fem::ConstraintTemperature'))
        self.assertTrue(ObjectsFem.makeConstraintTransform(doc).isDerivedFrom('Fem::ConstraintTransform'))
        self.assertTrue(ObjectsFem.makeElementFluid1D(doc).isDerivedFrom('Fem::FeaturePython'))
        self.assertTrue(ObjectsFem.makeElementGeometry1D(doc).isDerivedFrom('Fem::FeaturePython'))
        self.assertTrue(ObjectsFem.makeElementGeometry2D(doc).isDerivedFrom('Fem::FeaturePython'))
        self.assertTrue(ObjectsFem.makeElementRotation1D(doc).isDerivedFrom('Fem::FeaturePython'))
        materialsolid = ObjectsFem.makeMaterialSolid(doc)
        self.assertTrue(ObjectsFem.makeMaterialFluid(doc).isDerivedFrom('App::MaterialObjectPython'))
        self.assertTrue(materialsolid.isDerivedFrom('App::MaterialObjectPython'))
        self.assertTrue(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid).isDerivedFrom('Fem::FeaturePython'))
        mesh = ObjectsFem.makeMeshGmsh(doc)
        self.assertTrue(mesh.isDerivedFrom('Fem::FemMeshObjectPython'))
        self.assertTrue(ObjectsFem.makeMeshBoundaryLayer(doc, mesh).isDerivedFrom('Fem::FeaturePython'))
        self.assertTrue(ObjectsFem.makeMeshGroup(doc, mesh).isDerivedFrom('Fem::FeaturePython'))
        self.assertTrue(ObjectsFem.makeMeshRegion(doc, mesh).isDerivedFrom('Fem::FeaturePython'))
        self.assertTrue(ObjectsFem.makeMeshNetgen(doc).isDerivedFrom('Fem::FemMeshShapeNetgenObject'))
        self.assertTrue(ObjectsFem.makeMeshResult(doc).isDerivedFrom('Fem::FemMeshObjectPython'))
        self.assertTrue(ObjectsFem.makeResultMechanical(doc).isDerivedFrom('Fem::FemResultObjectPython'))
        solverelmer = ObjectsFem.makeSolverElmer(doc)
        self.assertTrue(ObjectsFem.makeSolverCalculixCcxTools(doc).isDerivedFrom('Fem::FemSolverObjectPython'))
        self.assertTrue(ObjectsFem.makeSolverCalculix(doc).isDerivedFrom('Fem::FemSolverObjectPython'))
        self.assertTrue(solverelmer.isDerivedFrom('Fem::FemSolverObjectPython'))
        self.assertTrue(ObjectsFem.makeSolverZ88(doc).isDerivedFrom('Fem::FemSolverObjectPython'))
        self.assertTrue(ObjectsFem.makeEquationElasticity(doc, solverelmer).isDerivedFrom('App::FeaturePython'))
        self.assertTrue(ObjectsFem.makeEquationElectrostatic(doc, solverelmer).isDerivedFrom('App::FeaturePython'))
        self.assertTrue(ObjectsFem.makeEquationFlow(doc, solverelmer).isDerivedFrom('App::FeaturePython'))
        self.assertTrue(ObjectsFem.makeEquationFluxsolver(doc, solverelmer).isDerivedFrom('App::FeaturePython'))
        self.assertTrue(ObjectsFem.makeEquationHeat(doc, solverelmer).isDerivedFrom('App::FeaturePython'))
开发者ID:KimK,项目名称:FreeCAD,代码行数:52,代码来源:testobject.py

示例5: test_femobjects_isoftype

# 需要导入模块: import ObjectsFem [as 别名]
# 或者: from ObjectsFem import makeMeshResult [as 别名]
    def test_femobjects_isoftype(self):
        doc = self.active_doc

        from femtools.femutils import is_of_type
        self.assertTrue(is_of_type(ObjectsFem.makeAnalysis(doc), 'Fem::FemAnalysis'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintBearing(doc), 'Fem::ConstraintBearing'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintBodyHeatSource(doc), 'Fem::ConstraintBodyHeatSource'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintContact(doc), 'Fem::ConstraintContact'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintDisplacement(doc), 'Fem::ConstraintDisplacement'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintElectrostaticPotential(doc), 'Fem::ConstraintElectrostaticPotential'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintFixed(doc), 'Fem::ConstraintFixed'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintFlowVelocity(doc), 'Fem::ConstraintFlowVelocity'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintFluidBoundary(doc), 'Fem::ConstraintFluidBoundary'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintForce(doc), 'Fem::ConstraintForce'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintGear(doc), 'Fem::ConstraintGear'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintHeatflux(doc), 'Fem::ConstraintHeatflux'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintInitialFlowVelocity(doc), 'Fem::ConstraintInitialFlowVelocity'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintInitialTemperature(doc), 'Fem::ConstraintInitialTemperature'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintPlaneRotation(doc), 'Fem::ConstraintPlaneRotation'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintPressure(doc), 'Fem::ConstraintPressure'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintPulley(doc), 'Fem::ConstraintPulley'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintSelfWeight(doc), 'Fem::ConstraintSelfWeight'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintTemperature(doc), 'Fem::ConstraintTemperature'))
        self.assertTrue(is_of_type(ObjectsFem.makeConstraintTransform(doc), 'Fem::ConstraintTransform'))
        self.assertTrue(is_of_type(ObjectsFem.makeElementFluid1D(doc), 'Fem::FemElementFluid1D'))
        self.assertTrue(is_of_type(ObjectsFem.makeElementGeometry1D(doc), 'Fem::FemElementGeometry1D'))
        self.assertTrue(is_of_type(ObjectsFem.makeElementGeometry2D(doc), 'Fem::FemElementGeometry2D'))
        self.assertTrue(is_of_type(ObjectsFem.makeElementRotation1D(doc), 'Fem::FemElementRotation1D'))
        materialsolid = ObjectsFem.makeMaterialSolid(doc)
        self.assertTrue(is_of_type(ObjectsFem.makeMaterialFluid(doc), 'Fem::Material'))
        self.assertTrue(is_of_type(materialsolid, 'Fem::Material'))
        self.assertTrue(is_of_type(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'Fem::MaterialMechanicalNonlinear'))
        mesh = ObjectsFem.makeMeshGmsh(doc)
        self.assertTrue(is_of_type(mesh, 'Fem::FemMeshGmsh'))
        self.assertTrue(is_of_type(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'Fem::FemMeshBoundaryLayer'))
        self.assertTrue(is_of_type(ObjectsFem.makeMeshGroup(doc, mesh), 'Fem::FemMeshGroup'))
        self.assertTrue(is_of_type(ObjectsFem.makeMeshRegion(doc, mesh), 'Fem::FemMeshRegion'))
        self.assertTrue(is_of_type(ObjectsFem.makeMeshNetgen(doc), 'Fem::FemMeshShapeNetgenObject'))
        self.assertTrue(is_of_type(ObjectsFem.makeMeshResult(doc), 'Fem::FemMeshResult'))
        self.assertTrue(is_of_type(ObjectsFem.makeResultMechanical(doc), 'Fem::FemResultMechanical'))
        solverelmer = ObjectsFem.makeSolverElmer(doc)
        self.assertTrue(is_of_type(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverCalculixCcxTools'))
        self.assertTrue(is_of_type(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObjectCalculix'))
        self.assertTrue(is_of_type(solverelmer, 'Fem::FemSolverObjectElmer'))
        self.assertTrue(is_of_type(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObjectZ88'))
        self.assertTrue(is_of_type(ObjectsFem.makeEquationElasticity(doc, solverelmer), 'Fem::FemEquationElmerElasticity'))
        self.assertTrue(is_of_type(ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'Fem::FemEquationElmerElectrostatic'))
        self.assertTrue(is_of_type(ObjectsFem.makeEquationFlow(doc, solverelmer), 'Fem::FemEquationElmerFlow'))
        self.assertTrue(is_of_type(ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'Fem::FemEquationElmerFluxsolver'))
        self.assertTrue(is_of_type(ObjectsFem.makeEquationHeat(doc, solverelmer), 'Fem::FemEquationElmerHeat'))
开发者ID:KimK,项目名称:FreeCAD,代码行数:52,代码来源:testobject.py

示例6: test_femobjects_derivedfromfem

# 需要导入模块: import ObjectsFem [as 别名]
# 或者: from ObjectsFem import makeMeshResult [as 别名]

#.........这里部分代码省略.........
        self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTemperature(doc), 'Fem::Constraint'))
        self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTemperature(doc), 'Fem::ConstraintTemperature'))

        self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTransform(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTransform(doc), 'Fem::ConstraintTransform'))

        self.assertTrue(is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'Fem::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'Fem::FemElementFluid1D'))

        self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'Fem::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'Fem::FemElementGeometry1D'))

        self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'Fem::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'Fem::FemElementGeometry2D'))

        self.assertTrue(is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'Fem::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'Fem::FemElementRotation1D'))

        self.assertTrue(is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'App::MaterialObjectPython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'Fem::Material'))

        self.assertTrue(is_derived_from(materialsolid, 'App::DocumentObject'))
        self.assertTrue(is_derived_from(materialsolid, 'App::MaterialObjectPython'))
        self.assertTrue(is_derived_from(materialsolid, 'Fem::Material'))

        self.assertTrue(is_derived_from(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'Fem::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'Fem::MaterialMechanicalNonlinear'))

        self.assertTrue(is_derived_from(mesh, 'App::DocumentObject'))
        self.assertTrue(is_derived_from(mesh, 'Fem::FemMeshObjectPython'))
        self.assertTrue(is_derived_from(mesh, 'Fem::FemMeshGmsh'))

        self.assertTrue(is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'Fem::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'Fem::FemMeshBoundaryLayer'))

        self.assertTrue(is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'Fem::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'Fem::FemMeshGroup'))

        self.assertTrue(is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'Fem::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'Fem::FemMeshRegion'))

        self.assertTrue(is_derived_from(ObjectsFem.makeMeshNetgen(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshNetgen(doc), 'Fem::FemMeshShapeNetgenObject'))

        self.assertTrue(is_derived_from(ObjectsFem.makeMeshResult(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshResult(doc), 'Fem::FemMeshObjectPython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeMeshResult(doc), 'Fem::FemMeshResult'))

        self.assertTrue(is_derived_from(ObjectsFem.makeResultMechanical(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeResultMechanical(doc), 'Fem::FemResultObjectPython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeResultMechanical(doc), 'Fem::FemResultMechanical'))

        self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverObjectPython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverCalculixCcxTools'))

        self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObjectPython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObjectCalculix'))

        self.assertTrue(is_derived_from(solverelmer, 'App::DocumentObject'))
        self.assertTrue(is_derived_from(solverelmer, 'Fem::FemSolverObject'))
        self.assertTrue(is_derived_from(solverelmer, 'Fem::FemSolverObjectPython'))
        self.assertTrue(is_derived_from(solverelmer, 'Fem::FemSolverObjectElmer'))

        self.assertTrue(is_derived_from(ObjectsFem.makeSolverZ88(doc), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObjectPython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObjectZ88'))

        self.assertTrue(is_derived_from(ObjectsFem.makeEquationElasticity(doc, solverelmer), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationElasticity(doc, solverelmer), 'App::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationElasticity(doc, solverelmer), 'Fem::FemEquationElmerElasticity'))

        self.assertTrue(is_derived_from(ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'App::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'Fem::FemEquationElmerElectrostatic'))

        self.assertTrue(is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'App::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'Fem::FemEquationElmerFlow'))

        self.assertTrue(is_derived_from(ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'App::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'Fem::FemEquationElmerFluxsolver'))

        self.assertTrue(is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'App::DocumentObject'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'App::FeaturePython'))
        self.assertTrue(is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'Fem::FemEquationElmerHeat'))
开发者ID:KimK,项目名称:FreeCAD,代码行数:104,代码来源:testobject.py

示例7: importFrd

# 需要导入模块: import ObjectsFem [as 别名]
# 或者: from ObjectsFem import makeMeshResult [as 别名]
def importFrd(
    filename,
    analysis=None,
    result_name_prefix=None
):
    from . import importToolsFem
    import ObjectsFem
    if result_name_prefix is None:
        result_name_prefix = ''
    m = read_frd_result(filename)
    result_mesh_object = None
    if len(m['Nodes']) > 0:
        if analysis:
            analysis_object = analysis

        mesh = importToolsFem.make_femmesh(m)
        result_mesh_object = ObjectsFem.makeMeshResult(
            FreeCAD.ActiveDocument,
            'Result_mesh'
        )
        result_mesh_object.FemMesh = mesh

        number_of_increments = len(m['Results'])
        FreeCAD.Console.PrintLog(
            'Increments: ' + str(number_of_increments) + '\n'
        )
        if len(m['Results']) > 0:
            for result_set in m['Results']:
                if 'number' in result_set:
                    eigenmode_number = result_set['number']
                else:
                    eigenmode_number = 0
                step_time = result_set['time']
                step_time = round(step_time, 2)
                if eigenmode_number > 0:
                    results_name = (
                        '{}mode_{}_results'
                        .format(result_name_prefix, eigenmode_number)
                    )
                elif number_of_increments > 1:
                    results_name = (
                        '{}time_{}_results'
                        .format(result_name_prefix, step_time)
                    )
                else:
                    results_name = (
                        '{}results'
                        .format(result_name_prefix)
                    )

                res_obj = ObjectsFem.makeResultMechanical(FreeCAD.ActiveDocument, results_name)
                res_obj.Mesh = result_mesh_object
                res_obj = importToolsFem.fill_femresult_mechanical(res_obj, result_set)
                if analysis:
                    analysis_object.addObject(res_obj)
                # complementary result object calculations
                import femresult.resulttools as restools
                if not res_obj.MassFlowRate:
                    # only compact result if not Flow 1D results
                    # compact result object, workaround for bug 2873
                    # https://www.freecadweb.org/tracker/view.php?id=2873
                    res_obj = restools.compact_result(res_obj)
                # fill DisplacementLengths
                res_obj = restools.add_disp_apps(res_obj)
                # fill StressValues
                res_obj = restools.add_von_mises(res_obj)
                # fill PrincipalMax, PrincipalMed, PrincipalMin, MaxShear
                res_obj = restools.add_principal_stress(res_obj)
                # fill Stats
                res_obj = restools.fill_femresult_stats(res_obj)
        else:
            error_message = (
                "We have nodes but no results in frd file, "
                "which means we only have a mesh in frd file. "
                "Usually this happens for analysis type 'NOANALYSIS' "
                "or if CalculiX returned no results because "
                "of nonpositive jacobian determinant in at least one element.\n"
            )
            FreeCAD.Console.PrintMessage(error_message)
            if analysis:
                analysis_object.addObject(result_mesh_object)

        if FreeCAD.GuiUp:
            if analysis:
                import FemGui
                FemGui.setActiveAnalysis(analysis_object)
            FreeCAD.ActiveDocument.recompute()

    else:
        FreeCAD.Console.PrintError(
            'Problem on frd file import. No nodes found in frd file.\n'
        )
    return res_obj
开发者ID:ianrrees,项目名称:FreeCAD_tinkering,代码行数:95,代码来源:importCcxFrdResults.py

示例8: importFrd

# 需要导入模块: import ObjectsFem [as 别名]
# 或者: from ObjectsFem import makeMeshResult [as 别名]
def importFrd(filename, analysis=None, result_name_prefix=None):
    from . import importToolsFem
    import ObjectsFem
    if result_name_prefix is None:
        result_name_prefix = ''
    m = readResult(filename)
    result_mesh_object = None
    if len(m['Nodes']) > 0:
        if analysis:
            analysis_object = analysis

        mesh = importToolsFem.make_femmesh(m)
        result_mesh_object = ObjectsFem.makeMeshResult(FreeCAD.ActiveDocument, 'Result_mesh')
        result_mesh_object.FemMesh = mesh

        positions = []
        for k, v in m['Nodes'].items():
            positions.append(v)
        p_x_max, p_y_max, p_z_max = map(max, zip(*positions))
        p_x_min, p_y_min, p_z_min = map(min, zip(*positions))
        x_span = abs(p_x_max - p_x_min)
        y_span = abs(p_y_max - p_y_min)
        z_span = abs(p_z_max - p_z_min)
        span = max(x_span, y_span, z_span)

        number_of_increments = len(m['Results'])
        if len(m['Results']) > 0:
            for result_set in m['Results']:
                if 'number' in result_set:
                    eigenmode_number = result_set['number']
                else:
                    eigenmode_number = 0
                step_time = result_set['time']
                step_time = round(step_time, 2)
                if eigenmode_number > 0:
                    results_name = result_name_prefix + 'mode_' + str(eigenmode_number) + '_results'
                elif number_of_increments > 1:
                    results_name = result_name_prefix + 'time_' + str(step_time) + '_results'
                else:
                    results_name = result_name_prefix + 'results'

                results = ObjectsFem.makeResultMechanical(FreeCAD.ActiveDocument, results_name)
                results.Mesh = result_mesh_object
                results = importToolsFem.fill_femresult_mechanical(results, result_set, span)
                if analysis:
                    analysis_object.addObject(results)
        else:
            error_message = (
                "We have nodes but no results in frd file, which means we only have a mesh in frd file. "
                "Usually this happens for analysis type 'NOANALYSIS' or if CalculiX returned no results because "
                "of nonpositive jacobian determinant in at least one element.\n"
            )
            FreeCAD.Console.PrintMessage(error_message)
            if analysis:
                analysis_object.addObject(result_mesh_object)

        if FreeCAD.GuiUp:
            if analysis:
                import FemGui
                FemGui.setActiveAnalysis(analysis_object)
            FreeCAD.ActiveDocument.recompute()

    else:
        FreeCAD.Console.PrintError('Problem on frd file import. No nodes found in frd file.\n')
开发者ID:KeithSloan,项目名称:FreeCAD_sf_master,代码行数:66,代码来源:importCcxFrdResults.py


注:本文中的ObjectsFem.makeMeshResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。